Skip to content

Toast

Announce transient status from an explicit toaster. Custom element

Toast
Copy this markup
<ui-toaster role="region" aria-label="Notifications" placement="bottom-end" stack="overlap">
<ui-toast role="status">
<div data-ui-part="content">
<h2 data-ui-part="title">Preview ready</h2>
<p data-ui-part="description">The static example finished building.</p>
</div>
<button data-ui-part="close" type="button" aria-label="Dismiss notification">
<svg aria-hidden="true" focusable="false" viewBox="0 0 16 16">
<path d="m4.5 4.5 7 7m0-7-7 7" fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="1"/>
</svg>
</button>
</ui-toast>
</ui-toaster>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/toast.css'
import '@timelessui/components/define/ui-toaster'
import '@timelessui/components/define/ui-toast'

Anatomy

Parts are authored in your own markup and identified by the selector below, so your CSS can target the same anatomy without loading Timeless styles. Required parts must be present for the component to work. Private data-ui-internal-* hooks are written by the runtime and must never be authored.

<ui-toast>

PartRequiredSelectorPurpose
contentNo[data-ui-part~='content']Wrapper for the title and description.
titleNo[data-ui-part~='title']Short summary line.
descriptionNo[data-ui-part~='description']Supporting detail.
closeNo[data-ui-part~='close']Dismiss button. Give it an accessible name.

Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes are presence-based: author the attribute with no value, or omit it.

<ui-toaster>

AttributeValuesDefaultDescription
placementtop-start · top-center · top-end · bottom-start · bottom-center · bottom-endbottom-endCorner or edge of the viewport the toasts stack against.
stackoverlap · listoverlapWhether queued toasts overlap into a deck (overlap) or lay out as a full list (list).

<ui-toast>

AttributeValuesDefaultDescription
durationany number5000Milliseconds before the toast dismisses itself. 0 keeps it open until dismissed.
persistentpresenceabsentPresent to disable auto-dismiss regardless of duration.

Element API

Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.

<ui-toaster>

PropertyTypeNotes
placement'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end'Reflects the placement attribute, documented above.
stack'overlap' | 'list'Reflects the stack attribute, documented above.

This element dispatches no component events.

<ui-toast>

PropertyTypeNotes
durationstringReflects the duration attribute, documented above.
persistentbooleanReflects the persistent attribute, documented above.
EventDetailDescription
ui-dismissCustomEvent<ToastDismissDetail>Dispatched when the toast is dismissed. The detail names the reason: a timeout, the close control, or the imperative API.

Styling

Root identity: ui-toaster, ui-toast. Required stylesheets: tokens.css, toast.css.

Set these custom properties to restyle the component:

Custom propertyControls
--ui-toaster-gapGap between toasts in list mode.
--ui-toaster-overlapOffset between stacked toasts in overlap mode.
Design tokens this component reads (13)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-bg-control · --ui-bg-surface · --ui-fg · --ui-fg-muted · --ui-focus · --ui-line · --ui-radius-lg · --ui-radius-md · --ui-shadow-floating · --ui-space-1 · --ui-space-3 · --ui-space-4 · --ui-space-5

Accessibility

Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.

Before JavaScript runs

The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.

More examples

Open Toast in StoryLite for variants, controls, and manual testing.