◇
Toast
7 partsAnatomy
Import the parts and compose them. Each part forwards attributes to its underlying element.
vue
import {
ToastProvider,
ToastRoot,
ToastTitle,
ToastDescription,
ToastAction,
ToastClose,
ToastViewport,
} from '@robonen/primitives/toast';
<ToastProvider>
<ToastRoot />
<ToastTitle />
<ToastDescription />
<ToastAction />
<ToastClose />
<ToastViewport />
</ToastProvider>API Reference
ToastProvider
Provider| Prop | Type | Description |
|---|---|---|
label? | string | Accessible label for the toast region. |
duration? | number | Auto-dismiss duration in ms. Use `Infinity` to disable auto-dismiss. |
swipeDirection? | SwipeDirection | Swipe direction to dismiss. |
swipeThreshold? | number | Minimum swipe distance before a dismiss gesture is recognised. |
ToastRoot
Root| Prop | Type | Description |
|---|---|---|
duration? | number | Override the provider's auto-dismiss duration. Use `Infinity` to disable. |
type? | 'foreground' | 'background' | Toast type — controls the `aria-live` politeness. |
ToastTitle
TitleNo props or events — renders its element and forwards attributes.
ToastDescription
DescriptionNo props or events — renders its element and forwards attributes.
ToastAction
Action| Prop | Type | Description |
|---|---|---|
altText | string | Accessible description for screen readers (required). Describes what happens when the user triggers the action. |
ToastClose
CloseNo props or events — renders its element and forwards attributes.
ToastViewport
Viewport| Prop | Type | Description |
|---|---|---|
label? | string | Accessible label for the toast region. Overrides the provider label. |
hotkey? | string[] | Keyboard shortcut to focus the viewport. |