Skip to main content
PROYECTOVIVIANA

Toast

Toasts display brief, temporary notifications. They appear at the edge of the screen and automatically dismiss after a timeout.

Import

import {
  ToastProvider,
  ToastRegion,
  toastSuccess,
  toastError,
  toastWarning,
  toastInfo
} from '@proyecto-viviana/solid-spectrum';

Setup

Wrap your app with ToastProvider and add ToastRegion where you want toasts to appear.

function App() {
  return (
    <ToastProvider>
      <YourApp />
      <ToastRegion placement="bottom end" />
    </ToastProvider>
  );
}

Toast Variants

Use helper functions to show different toast types.

toastSuccess('Changes saved successfully!');
toastError('Failed to save changes');
toastWarning('Your session will expire soon');
toastInfo('New update available');

Custom Duration

Control how long the toast stays visible.

toastSuccess('Quick message', { timeout: 2000 });
toastInfo('Stays longer', { timeout: 10000 });

Placement Options

Toasts can appear at different edges of the screen.

Placement options: top, top end, bottom, bottom end
<ToastRegion placement="top" />
<ToastRegion placement="top end" />
<ToastRegion placement="bottom end" />

ToastProvider Props

Props

PropTypeDefaultDescription
childrenJSX.ElementApp content

ToastRegion Props

Props

PropTypeDefaultDescription
placement'top' | 'top end' | 'bottom' | 'bottom end''bottom'Where toasts appear on screen
aria-labelstring'Notifications'Accessible label for the region

Toast Helper Options

Props

PropTypeDefaultDescription
timeoutnumber5000Duration in milliseconds before auto-dismiss
prioritynumber0Higher priority toasts appear first

Accessibility

  • Uses role="region" with aria-label
  • Individual toasts use role="alert" for screen reader announcements
  • Focus pauses the auto-dismiss timer
  • Hover pauses the auto-dismiss timer
  • Escape key dismisses the focused toast
  • Toasts are announced to screen readers via live regions