We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Toast Component

The Toast component delivers brief, non-intrusive notifications that automatically appear and disappear. Perfect for providing feedback on user actions, displaying system status, or communicating important updates without disrupting the user experience.

  • Check Circle

    Multiple Positions: Four strategic placement options

  • Check Circle

    Message Variants: Success and error states

  • Check Circle

    Auto-dismiss: Configurable display duration

  • Check Circle

    Accessible: Screen reader and keyboard support

Add the Toast component to your layout and trigger it programmatically:

<Toast id="my-toast" position="bottomRight" />
// Show a success message
const toast = await Ready(document.querySelector<ToastElement>('#my-toast'));
toast.show({
message: 'Changes saved successfully!',
variant: 'success',
duration: 3000,
});

Toast Component Props Extends <div> HTMLElement
Prop Type Default Description
position topLeft | topRight | bottomLeft | bottomRight bottomRight Toast position on screen
buttonProps ButtonProps {} Props for close button
interface ToastData {
show: ({ message, duration, variant }: { message: string; duration?: number; variant?: 'success' | 'error' }) => void;
hide: () => void;
}
  1. Message Content

    • Keep messages brief and clear
    • Use appropriate variants for context
    • Include specific details when helpful
    • Avoid technical jargon
  2. Timing and Display

    • Set appropriate duration for message length
    • Limit simultaneous toasts
    • Position consistently throughout app
    • Consider mobile viewports
  3. Accessibility

    • Use ARIA live regions
    • Ensure keyboard accessibility
    • Provide sufficient contrast
    • Allow manual dismissal
Form submission feedback
Save confirmations
Error notifications
Update notifications
Session expiration
Connection status

Limited Time Launch Sale

Add polished notifications to your website today with our Toast component. Get the AstroJS starter template and enhance your user experience instantly.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes