Toast Component

A modern, accessible toast notification system using the native Popover API. Supports multiple types, positions, and programmatic usage.

Features

  • Native Popover API: Uses browser-native popover for better performance
  • Multiple Types: Success, Danger, Warning, Info
  • Flexible Positioning: Top/Bottom × Center/Right
  • Auto-dismiss: Configurable duration or manual dismiss
  • Programmatic API: Easy-to-use toast manager
  • Beautiful Design: Glassmorphism with smooth animations
  • Dark Mode: Full dark mode support
  • Type-Safe: Full TypeScript support

Installation

The component is available in @monorepo/solid-pkg-ui:

Setup

Add the ToastContainer to your app root or layout:

Usage

The easiest way to show toasts is using the toast manager:

Component Usage

You can also use the Toast component directly:

API Reference

toast Manager

Methods

Options

Toast Component Props

Types

Best Practices

  1. Use Appropriate Types:
    • success: Confirmations, successful operations
    • danger: Errors, failures, critical issues
    • warning: Warnings, confirmations needed
    • info: General information, tips
  2. Set Reasonable Durations:
    • Success: 3000ms (3 seconds)
    • Error: 5000ms (5 seconds)
    • Warning: 0 (manual dismiss) or 7000ms
    • Info: 4000ms
  3. Keep Messages Concise:
    • Title: 1-3 words
    • Message: 1-2 sentences max
  4. Choose the Right Position:
    • top-right: Default, non-intrusive
    • top-center: Important notifications
    • bottom-right: Background processes
    • bottom-center: Form validations

Accessibility

  • ✅ Keyboard accessible (close with Escape)
  • ✅ Screen reader friendly
  • ✅ High contrast colors
  • ✅ Clear visual indicators
  • ✅ Proper ARIA labels