R

Toast

7 parts

Anatomy

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
PropTypeDescription
label?stringAccessible label for the toast region.
duration?numberAuto-dismiss duration in ms. Use `Infinity` to disable auto-dismiss.
swipeDirection?SwipeDirectionSwipe direction to dismiss.
swipeThreshold?numberMinimum swipe distance before a dismiss gesture is recognised.

ToastRoot

Root
PropTypeDescription
duration?numberOverride the provider's auto-dismiss duration. Use `Infinity` to disable.
type?'foreground' | 'background'Toast type — controls the `aria-live` politeness.

ToastTitle

Title

No props or events — renders its element and forwards attributes.

ToastDescription

Description

No props or events — renders its element and forwards attributes.

ToastAction

Action
PropTypeDescription
altTextstringAccessible description for screen readers (required). Describes what happens when the user triggers the action.

ToastClose

Close

No props or events — renders its element and forwards attributes.

ToastViewport

Viewport
PropTypeDescription
label?stringAccessible label for the toast region. Overrides the provider label.
hotkey?string[]Keyboard shortcut to focus the viewport.