Alert
A hand-drawn styled alert component for displaying important messages, notifications, and feedback to users.
Alert
The Alert component in Faiz UI provides a hand-drawn sketch aesthetic for displaying important messages, notifications, and feedback to users. It supports various colors, styles, and customization options to match different use cases and severity levels.
Usage
Colors
Alerts come in various color options to convey different meanings and priority levels.
Variants
The Alert component offers multiple style variants to suit different UI contexts.
Border Radius
Control the border radius of alerts to match your design requirements.
Custom Icon
You can customize the icon displayed in the alert to better match your message's context.
Without Icon
Hide the icon when it's not needed by setting the hideIcon
prop to true
.
With Action
Add action buttons to your alerts to provide users with immediate response options.
With Close Button
Include a close button for dismissible alerts by providing an onClose
callback.
Controlled Visibility
Control the visibility of alerts programmatically using the isVisible
prop.
Custom Styles
Apply custom styles using Tailwind CSS classes to create unique alert appearances.
Sketchy Variant
The signature sketchy style variant enhances the hand-drawn aesthetic of the alert component.
Implementation Notes
- The Alert component automatically selects appropriate icons based on the color prop if no custom icon is provided.
- The component is fully responsive and adapts to containers of different sizes.
- Alert visibility can be controlled both with the
isVisible
prop and the built-in close button functionality. - The hand-drawn aesthetic is consistently applied across all variants and states.
- All alerts are fully accessible with proper ARIA attributes and keyboard navigation support.
Props
Prop | Type | Default | Description |
---|---|---|---|
color | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | The color theme of the alert |
variant | 'solid' | 'outline' | 'ghost' | 'light' | 'flat' | 'sketchy' | 'solid' | The visual style variant of the alert |
radius | 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'md' | The border radius of the alert |
hideIcon | boolean | false | Whether to hide the icon |
icon | React.ReactNode | undefined | Custom icon to display in the alert |
action | React.ReactNode | undefined | Action component to display in the alert |
isVisible | boolean | true | Whether the alert is visible |
onClose | () => void | undefined | Callback fired when the alert is closed |
customStyles | string | undefined | Custom Tailwind CSS classes for additional styling |