Overview
TheNotification component displays inline messages with visual status indicators. It supports five status types (success, warning, error, info, neutral) and can include action buttons or custom content.
Basic Usage
Status Types
Success
For positive confirmations and successful operations:Warning
For cautionary messages that need attention:Error
For error messages and failed operations:Info
For informational messages:Neutral
For general notifications without status emphasis:Title Only
For compact notifications without descriptions:With Action Buttons
Use thechildren snippet to add action buttons:
Multiple Actions
Props
The main notification message.
Optional secondary text providing additional context.
The notification status type. Determines the color scheme and icon.Possible values:
'success'- Green scheme with success icon'warning'- Yellow scheme with warning icon'error'- Red scheme with error icon'info'- Blue scheme with info icon'neutral'- Default gray scheme with info icon
Svelte snippet for custom content or action buttons displayed on the right side of the notification.
Visual Styles
The notification automatically adjusts its styling based on thetype prop:
| Type | Background | Text Color | Icon |
|---|---|---|---|
success | Light green | Green | Success checkmark |
warning | Light yellow | Yellow/orange | Warning triangle |
error | Light red | Red | Error X |
info | Light blue | Blue | Info circle |
neutral | Gray border | Default | Info circle |
Layout Behavior
- With description: Icon aligns to the top, allowing multi-line descriptions
- Title only: Icon centers vertically for a more compact appearance
- With children: Additional padding is added to accommodate action buttons
Toast Integration
While this component is designed for inline use, you can integrate it with a toast library like Sonner for temporary notifications:Accessibility
- Semantic HTML with proper heading hierarchy
- Color is not the only indicator of status (icons are also used)
- Sufficient color contrast ratios for text and icons
- Focus management for interactive elements (buttons)
TypeScript
The component is fully typed with theNotificationProps interface:
Related Components
- AlertDialog - For modal confirmations
- StatusLabel - For inline status indicators
- TagStatus - For status badges