Toast
Usage
Include CSS
Import Tailwind and one full A3S UI style bundle.
Or import only the base CSS, Toast component CSS, and one style pack.
Using CDN or bundler imports? See the Installation page.
Include JavaScript
Copy or serve the full A3S UI JavaScript bundle.
Or copy or serve the A3S UI runtime and Toast script.
Using CDN or bundler imports? See the Installation page.
Add the toaster HTML
Add one toaster near the end of your page body:
Set data-align="start", data-align="center", or data-align="end" on the toaster to change placement.
Add your toasts
Append server-rendered toast markup to the toaster, or create one from JavaScript with toaster.toast(config).
HTML structure
<div id="toaster" class="toaster">- Toast container. Optional
data-alignvalues arestart,center, andend. <div class="toast">Toast item. Use
data-category="success|info|warning|error"for category styling anddata-durationto override the timeout in milliseconds. Usedata-duration="-1"to keep it open.<div class="toast-content">Content wrapper.
<svg aria-hidden="true">Optional- Icon.
<section>Message region.
<h2>- Title.
<p>Optional- Description.
<footer>Optional- Action buttons or links. Clicking a footer button or link closes the toast.
JavaScript API
Config object
durationOptional- Timeout in milliseconds. Defaults to
3000, or5000for error toasts. Use-1to keep it open. categoryOptional- Category of the toast, either
success,info,warning, orerror. title- The title of the toast. It is rendered as text, not HTML.
descriptionOptional- The description of the toast. It is rendered as text, not HTML.
actionOptional- Primary action. Supports
label, optionalhref, and an optionalonClick(event)callback. cancelOptional- Secondary action. Supports
labeland an optionalonClick(event)callback.