Toasts
Short messages that appear over the page and go away on their own. Four helpers show and manage them: makeToast, updateToast, dismissToast, and clearToasts. This page covers variants and appearance, position, and the helpers. The container that shows the toasts is already in the blank layout, so every page can use them.
Appearance and variants
A toast has one of five variants (primary, success, info, warning, or danger) and one of two appearances. Subtle colours the whole toast. Outline keeps a neutral card and colours only the icon. Choose them with the variant and appearance options. The defaults are primary and outline. A toast can have an icon, a title, a message, an action link, and a close button; each of them is optional.
Subtle
<div>
<h3 class="mb-3 text-sm font-semibold text-dominant-900 dark:text-white">Subtle</h3>
<div class="space-y-3 max-w-sm">
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-primary-200 dark:border-primary-800 bg-primary-50 dark:bg-primary-950 text-primary-900 dark:text-primary-100"
>
<span
class="mt-0.5 flex size-5 shrink-0 items-center justify-center text-primary-700 dark:text-primary-300"
>
<i aria-hidden="true" class="fa-solid fa-star"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold">Primary</p>
<p class="mt-0.5 text-sm">A highlighted message for you.</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none hover:bg-dominant-900/10 dark:hover:bg-white/10"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-success-200 dark:border-success-800 bg-success-50 dark:bg-success-950 text-success-900 dark:text-success-100"
>
<span
class="mt-0.5 flex size-5 shrink-0 items-center justify-center text-success-700 dark:text-success-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-check"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold">Success</p>
<p class="mt-0.5 text-sm">Your changes were saved.</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none hover:bg-dominant-900/10 dark:hover:bg-white/10"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-info-200 dark:border-info-800 bg-info-50 dark:bg-info-950 text-info-900 dark:text-info-100"
>
<span
class="mt-0.5 flex size-5 shrink-0 items-center justify-center text-info-700 dark:text-info-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-info"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold">Info</p>
<p class="mt-0.5 text-sm">A new version is available.</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none hover:bg-dominant-900/10 dark:hover:bg-white/10"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-warning-200 dark:border-warning-800 bg-warning-50 dark:bg-warning-950 text-warning-900 dark:text-warning-100"
>
<span
class="mt-0.5 flex size-5 shrink-0 items-center justify-center text-warning-700 dark:text-warning-300"
>
<i aria-hidden="true" class="fa-solid fa-triangle-exclamation"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold">Warning</p>
<p class="mt-0.5 text-sm">Storage is almost full.</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none hover:bg-dominant-900/10 dark:hover:bg-white/10"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="alert"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-danger-200 dark:border-danger-800 bg-danger-50 dark:bg-danger-950 text-danger-900 dark:text-danger-100"
>
<span
class="mt-0.5 flex size-5 shrink-0 items-center justify-center text-danger-700 dark:text-danger-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-exclamation"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold">Danger</p>
<p class="mt-0.5 text-sm">The changes could not be saved.</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none hover:bg-dominant-900/10 dark:hover:bg-white/10"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
<div>
<h3 class="mb-3 text-sm font-semibold text-dominant-900 dark:text-white">Outline</h3>
<div class="space-y-3 max-w-sm">
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-dominant-200 dark:border-dominant-700 bg-white dark:bg-dominant-800"
>
<span
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-primary-100 dark:bg-primary-900/50 text-primary-700 dark:text-primary-300"
>
<i aria-hidden="true" class="fa-solid fa-star"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold text-dominant-900 dark:text-white">Primary</p>
<p class="mt-0.5 text-sm text-dominant-600 dark:text-dominant-300">
A highlighted message for you.
</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-primary-700 dark:text-primary-300 hover:underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-dominant-600 dark:text-dominant-300 hover:bg-dominant-100 dark:hover:bg-dominant-700 hover:text-dominant-900 dark:hover:text-white"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-dominant-200 dark:border-dominant-700 bg-white dark:bg-dominant-800"
>
<span
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-success-100 dark:bg-success-900/50 text-success-800 dark:text-success-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-check"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold text-dominant-900 dark:text-white">Success</p>
<p class="mt-0.5 text-sm text-dominant-600 dark:text-dominant-300">
Your changes were saved.
</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-success-800 dark:text-success-300 hover:underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-dominant-600 dark:text-dominant-300 hover:bg-dominant-100 dark:hover:bg-dominant-700 hover:text-dominant-900 dark:hover:text-white"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-dominant-200 dark:border-dominant-700 bg-white dark:bg-dominant-800"
>
<span
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-info-100 dark:bg-info-900/50 text-info-800 dark:text-info-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-info"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold text-dominant-900 dark:text-white">Info</p>
<p class="mt-0.5 text-sm text-dominant-600 dark:text-dominant-300">
A new version is available.
</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-info-800 dark:text-info-300 hover:underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-dominant-600 dark:text-dominant-300 hover:bg-dominant-100 dark:hover:bg-dominant-700 hover:text-dominant-900 dark:hover:text-white"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="status"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-dominant-200 dark:border-dominant-700 bg-white dark:bg-dominant-800"
>
<span
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-warning-100 dark:bg-warning-900/50 text-warning-800 dark:text-warning-300"
>
<i aria-hidden="true" class="fa-solid fa-triangle-exclamation"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold text-dominant-900 dark:text-white">Warning</p>
<p class="mt-0.5 text-sm text-dominant-600 dark:text-dominant-300">
Storage is almost full.
</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-warning-800 dark:text-warning-300 hover:underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-dominant-600 dark:text-dominant-300 hover:bg-dominant-100 dark:hover:bg-dominant-700 hover:text-dominant-900 dark:hover:text-white"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
<div
role="alert"
class="flex w-full items-start gap-3 rounded-xl border p-4 shadow-lg motion-safe:animate-toast-in border-dominant-200 dark:border-dominant-700 bg-white dark:bg-dominant-800"
>
<span
class="flex size-9 shrink-0 items-center justify-center rounded-full bg-danger-100 dark:bg-danger-900/50 text-danger-800 dark:text-danger-300"
>
<i aria-hidden="true" class="fa-solid fa-circle-exclamation"> </i>
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-semibold text-dominant-900 dark:text-white">Danger</p>
<p class="mt-0.5 text-sm text-dominant-600 dark:text-dominant-300">
The changes could not be saved.
</p>
<a
href="#"
class="cursor-pointer mt-2 inline-block rounded text-sm font-semibold focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-danger-800 dark:text-danger-300 hover:underline"
>Action</a
>
</div>
<button
type="button"
aria-label="Dismiss notification"
class="cursor-pointer transition-colors flex size-8 shrink-0 items-center justify-center rounded-lg focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none text-dominant-600 dark:text-dominant-300 hover:bg-dominant-100 dark:hover:bg-dominant-700 hover:text-dominant-900 dark:hover:text-white"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
Show a toast
Call Starkit.makeToast(config) to show a toast. It returns the id of the toast. You can call it from an Alpine expression (x-on:click), from an onclick attribute, or from your own script. Each button below shows a toast of its variant. The toast closes after 5 seconds, when its close button is pressed, or when its action link is clicked.
<button
id="button-1477"
type="button"
x-on:click="Starkit.makeToast({ variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-star', title: 'Primary', message: 'A highlighted message for you.', actionText: 'Action', actionLink: '#', dismissible: true })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>primary</span>
</button>
<button
id="button-1621"
type="button"
x-on:click="Starkit.makeToast({ variant: 'success', appearance: 'subtle', icon: 'fa-solid fa-circle-check', title: 'Success', message: 'Your changes were saved.', actionText: 'Action', actionLink: '#', dismissible: true })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-success-500 text-success-950 shadow-sm not-disabled:hover:bg-success-400 not-disabled:active:bg-success-300 focus-visible:ring-success-700 dark:focus-visible:ring-success-400 gap-2 px-4 py-2.5 text-sm"
>
<span>success</span>
</button>
<button
id="button-1683"
type="button"
x-on:click="Starkit.makeToast({ variant: 'info', appearance: 'subtle', icon: 'fa-solid fa-circle-info', title: 'Info', message: 'A new version is available.', actionText: 'Action', actionLink: '#', dismissible: true })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-info-500 text-info-950 shadow-sm not-disabled:hover:bg-info-400 not-disabled:active:bg-info-300 focus-visible:ring-info-700 dark:focus-visible:ring-info-400 gap-2 px-4 py-2.5 text-sm"
>
<span>info</span>
</button>
<button
id="button-1746"
type="button"
x-on:click="Starkit.makeToast({ variant: 'warning', appearance: 'subtle', icon: 'fa-solid fa-triangle-exclamation', title: 'Warning', message: 'Storage is almost full.', actionText: 'Action', actionLink: '#', dismissible: true })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-warning-400 text-warning-950 shadow-sm not-disabled:hover:bg-warning-300 not-disabled:active:bg-warning-200 focus-visible:ring-warning-700 dark:focus-visible:ring-warning-400 gap-2 px-4 py-2.5 text-sm"
>
<span>warning</span>
</button>
<button
id="button-1791"
type="button"
x-on:click="Starkit.makeToast({ variant: 'danger', appearance: 'subtle', icon: 'fa-solid fa-circle-exclamation', title: 'Danger', message: 'The changes could not be saved.', actionText: 'Action', actionLink: '#', dismissible: true })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-danger-600 text-white shadow-sm not-disabled:hover:bg-danger-700 not-disabled:active:bg-danger-800 focus-visible:ring-danger-700 dark:focus-visible:ring-danger-400 gap-2 px-4 py-2.5 text-sm"
>
<span>danger</span>
</button>
Position
The position option decides where a toast appears: top-left, top-center, top-right (the default), bottom-left, bottom-center, or bottom-right. Toasts with the same position stack in one wrapper. The wrapper is created with its first toast and removed when its last toast closes.
<button
id="button-1478"
type="button"
x-on:click="Starkit.makeToast({ position: 'top-left', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Top left', message: 'This toast appears at the top left of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>top-left</span>
</button>
<button
id="button-1622"
type="button"
x-on:click="Starkit.makeToast({ position: 'top-center', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Top center', message: 'This toast appears at the top center of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>top-center</span>
</button>
<button
id="button-1684"
type="button"
x-on:click="Starkit.makeToast({ position: 'top-right', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Top right', message: 'This toast appears at the top right of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>top-right</span>
</button>
<button
id="button-1747"
type="button"
x-on:click="Starkit.makeToast({ position: 'bottom-left', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Bottom left', message: 'This toast appears at the bottom left of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>bottom-left</span>
</button>
<button
id="button-1792"
type="button"
x-on:click="Starkit.makeToast({ position: 'bottom-center', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Bottom center', message: 'This toast appears at the bottom center of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>bottom-center</span>
</button>
<button
id="button-1828"
type="button"
x-on:click="Starkit.makeToast({ position: 'bottom-right', variant: 'primary', appearance: 'subtle', icon: 'fa-solid fa-location-dot', title: 'Bottom right', message: 'This toast appears at the bottom right of the screen.' })"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>bottom-right</span>
</button>
Helpers
Four helpers manage all toasts. They are on window.Starkit, so any JavaScript can call them: an Alpine expression, an onclick attribute, or your own script. makeToast and updateToast take the options below.
Helpers
| Helper | Returns | What it does |
|---|---|---|
makeToast(config)
|
string
|
Shows a toast and returns its id. |
updateToast(id, config)
|
nothing | Changes the options of a toast that is still shown. The fields you pass replace the old ones, and the timer starts again. |
dismissToast(id)
|
nothing | Closes one toast by its id. |
clearToasts()
|
nothing | Closes all toasts. |
Options
| Option | Type | Default | Description |
|---|---|---|---|
title
|
string | none | The title of the toast. |
message
|
string | none | The message of the toast. |
actionText
|
string | none | The text of the action link. Without it there is no action link. |
actionLink
|
string |
#
|
The URL the action link opens. Clicking the link also closes the toast. |
actionTarget
|
string | none |
The target of the action link, for example _blank. With _blank, the link also gets rel="noopener noreferrer".
|
icon
|
string | none |
Font Awesome classes, for example fa-solid fa-star. Without an icon, none is shown.
|
dismissible
|
boolean |
false
|
Shows a close button. |
duration
|
number |
5000
|
How long the toast stays, in milliseconds. 0 keeps it until it is closed.
|
position
|
string |
top-right
|
top-left, top-center, top-right, bottom-left, bottom-center, or bottom-right.
|
variant
|
string |
primary
|
primary, success, info, warning, or danger.
|
appearance
|
string |
outline
|
subtle or outline.
|
<div>
<h3 class="mb-3 text-sm font-semibold text-dominant-900 dark:text-white">Helpers</h3>
<div
id="table-1535-wrapper"
class="isolate overflow-auto rounded-xl border border-dominant-200 dark:border-dominant-700 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:outline-none dark:focus-visible:ring-primary-400"
tabindex="0"
>
<table
id="table-1535"
class="w-full border-separate border-spacing-0 text-left text-sm [&_th]:px-4 [&_td]:px-4 [&_th]:whitespace-nowrap [&_td]:whitespace-nowrap [&_td]:text-dominant-700 dark:[&_td]:text-dominant-200 [&_tbody_th]:font-medium [&_tbody_th]:text-dominant-900 dark:[&_tbody_th]:text-white [&_thead_th]:text-xs [&_thead_th]:font-semibold [&_thead_th]:tracking-wide [&_thead_th]:uppercase [&_thead_tr:last-child>*]:border-b [&_thead_tr:last-child>*]:border-dominant-300 dark:[&_thead_tr:last-child>*]:border-dominant-600 [&_tbody>tr+tr>*]:border-t [&_tbody>tr>*]:border-dominant-200 dark:[&_tbody>tr>*]:border-dominant-700 [&_tfoot>tr>*]:border-t [&_tfoot>tr>*]:border-dominant-300 dark:[&_tfoot>tr>*]:border-dominant-600 [&_tfoot>tr>*]:font-semibold [&_thead_th]:bg-dominant-200 dark:[&_thead_th]:bg-dominant-700 [&_thead_th]:text-dominant-800 dark:[&_thead_th]:text-dominant-100 [&_thead_td]:bg-dominant-100 dark:[&_thead_td]:bg-dominant-800 [&_tfoot>tr>*]:bg-dominant-100 dark:[&_tfoot>tr>*]:bg-dominant-800 [&_tfoot>tr>*]:text-dominant-900 dark:[&_tfoot>tr>*]:text-white [&_.table-sticky-left]:sticky [&_.table-sticky-right]:sticky [&_tbody_.table-sticky-left]:z-10 [&_tbody_.table-sticky-right]:z-10 [&_tbody_.table-sticky-left]:bg-white dark:[&_tbody_.table-sticky-left]:bg-dominant-900 [&_tbody_.table-sticky-right]:bg-white dark:[&_tbody_.table-sticky-right]:bg-dominant-900 [&_thead_th.table-sticky-left]:z-30 [&_thead_th.table-sticky-right]:z-30 [&_thead_td.table-sticky-left]:z-10 [&_thead_td.table-sticky-right]:z-10 [&_th]:py-3 [&_td]:py-3"
>
<thead>
<tr>
<th scope="col">Helper</th>
<th scope="col">Returns</th>
<th scope="col">What it does</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>makeToast(config)</code>
</td>
<td>
<code>string</code>
</td>
<td>Shows a toast and returns its id.</td>
</tr>
<tr>
<td>
<code>updateToast(id, config)</code>
</td>
<td>nothing</td>
<td>
Changes the options of a toast that is still shown. The fields you pass replace the old
ones, and the timer starts again.
</td>
</tr>
<tr>
<td>
<code>dismissToast(id)</code>
</td>
<td>nothing</td>
<td>Closes one toast by its id.</td>
</tr>
<tr>
<td>
<code>clearToasts()</code>
</td>
<td>nothing</td>
<td>Closes all toasts.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<h3 class="mb-3 text-sm font-semibold text-dominant-900 dark:text-white">Options</h3>
<div
id="table-2017-wrapper"
class="isolate overflow-auto rounded-xl border border-dominant-200 dark:border-dominant-700 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:outline-none dark:focus-visible:ring-primary-400"
tabindex="0"
>
<table
id="table-2017"
class="w-full border-separate border-spacing-0 text-left text-sm [&_th]:px-4 [&_td]:px-4 [&_th]:whitespace-nowrap [&_td]:whitespace-nowrap [&_td]:text-dominant-700 dark:[&_td]:text-dominant-200 [&_tbody_th]:font-medium [&_tbody_th]:text-dominant-900 dark:[&_tbody_th]:text-white [&_thead_th]:text-xs [&_thead_th]:font-semibold [&_thead_th]:tracking-wide [&_thead_th]:uppercase [&_thead_tr:last-child>*]:border-b [&_thead_tr:last-child>*]:border-dominant-300 dark:[&_thead_tr:last-child>*]:border-dominant-600 [&_tbody>tr+tr>*]:border-t [&_tbody>tr>*]:border-dominant-200 dark:[&_tbody>tr>*]:border-dominant-700 [&_tfoot>tr>*]:border-t [&_tfoot>tr>*]:border-dominant-300 dark:[&_tfoot>tr>*]:border-dominant-600 [&_tfoot>tr>*]:font-semibold [&_thead_th]:bg-dominant-200 dark:[&_thead_th]:bg-dominant-700 [&_thead_th]:text-dominant-800 dark:[&_thead_th]:text-dominant-100 [&_thead_td]:bg-dominant-100 dark:[&_thead_td]:bg-dominant-800 [&_tfoot>tr>*]:bg-dominant-100 dark:[&_tfoot>tr>*]:bg-dominant-800 [&_tfoot>tr>*]:text-dominant-900 dark:[&_tfoot>tr>*]:text-white [&_.table-sticky-left]:sticky [&_.table-sticky-right]:sticky [&_tbody_.table-sticky-left]:z-10 [&_tbody_.table-sticky-right]:z-10 [&_tbody_.table-sticky-left]:bg-white dark:[&_tbody_.table-sticky-left]:bg-dominant-900 [&_tbody_.table-sticky-right]:bg-white dark:[&_tbody_.table-sticky-right]:bg-dominant-900 [&_thead_th.table-sticky-left]:z-30 [&_thead_th.table-sticky-right]:z-30 [&_thead_td.table-sticky-left]:z-10 [&_thead_td.table-sticky-right]:z-10 [&_th]:py-3 [&_td]:py-3"
>
<thead>
<tr>
<th scope="col">Option</th>
<th scope="col">Type</th>
<th scope="col">Default</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>title</code>
</td>
<td>string</td>
<td>none</td>
<td>The title of the toast.</td>
</tr>
<tr>
<td>
<code>message</code>
</td>
<td>string</td>
<td>none</td>
<td>The message of the toast.</td>
</tr>
<tr>
<td>
<code>actionText</code>
</td>
<td>string</td>
<td>none</td>
<td>The text of the action link. Without it there is no action link.</td>
</tr>
<tr>
<td>
<code>actionLink</code>
</td>
<td>string</td>
<td>
<code>#</code>
</td>
<td>The URL the action link opens. Clicking the link also closes the toast.</td>
</tr>
<tr>
<td>
<code>actionTarget</code>
</td>
<td>string</td>
<td>none</td>
<td>
The target of the action link, for example <code>_blank</code>. With
<code>_blank</code>, the link also gets <code>rel="noopener noreferrer"</code>.
</td>
</tr>
<tr>
<td>
<code>icon</code>
</td>
<td>string</td>
<td>none</td>
<td>
Font Awesome classes, for example <code>fa-solid fa-star</code>. Without an icon, none
is shown.
</td>
</tr>
<tr>
<td>
<code>dismissible</code>
</td>
<td>boolean</td>
<td>
<code>false</code>
</td>
<td>Shows a close button.</td>
</tr>
<tr>
<td>
<code>duration</code>
</td>
<td>number</td>
<td>
<code>5000</code>
</td>
<td>
How long the toast stays, in milliseconds. <code>0</code> keeps it until it is closed.
</td>
</tr>
<tr>
<td>
<code>position</code>
</td>
<td>string</td>
<td>
<code>top-right</code>
</td>
<td>
<code>top-left</code>, <code>top-center</code>, <code>top-right</code>,
<code>bottom-left</code>, <code>bottom-center</code>, or <code>bottom-right</code>.
</td>
</tr>
<tr>
<td>
<code>variant</code>
</td>
<td>string</td>
<td>
<code>primary</code>
</td>
<td>
<code>primary</code>, <code>success</code>, <code>info</code>, <code>warning</code>, or
<code>danger</code>.
</td>
</tr>
<tr>
<td>
<code>appearance</code>
</td>
<td>string</td>
<td>
<code>outline</code>
</td>
<td><code>subtle</code> or <code>outline</code>.</td>
</tr>
</tbody>
</table>
</div>
</div>