Alert
An Alert component is a UI element used to display important messages or notifications to users. It can convey different types of information such as success, warning, error, or informational messages, typically styled with distinct colors and icons to highlight the message's significance. Alerts are often used to grab the user's attention and provide immediate feedback on actions or events.
Rendered live, with the same build of the library you install.
Alert!
Information!
Success!
Warning!
Error!
Alert.tsx
import { AlertTypes, NAlert } from '@nayan-ui/react';const Alert = () => {return (<div><div className="space-y-3"><NAlert type={AlertTypes.DEFAULT} message="New version available!" onClose={() => console.log('Alert closed')} /><NAlert type={AlertTypes.INFO} message="New version available!" onClose={() => console.log('Alert closed')} /><NAlert type={AlertTypes.SUCCESS} message="New version available!" onClose={() => console.log('Alert closed')} /><NAlert type={AlertTypes.WARNING} message="New version available!" onClose={() => console.log('Alert closed')} /><NAlert type={AlertTypes.ERROR} title="Error!" message="New version available!" onClose={() => console.log('Alert closed')} /></div></div>);};export default Alert;
| Name | Type | Default | Details |
|---|---|---|---|
| type | AlertTypes | Required | You can pass type of the alert. |
| message | string | Optional | You can pass alert message. |
| title | string | Optional | You can pass alert title. |
| icon | React.ReactNode | Optional | Custom icon for the alert. |
| actions | React.ReactNode | Optional | Custom actions for the alert. |
| className | string | ' ' | You can customise by passing tailwind classes. |
| titleClassName | string | ' ' | You can customise by passing tailwind classes. |
| messageClassName | string | ' ' | You can customise by passing tailwind classes. |
| closeClassName | string | ' ' | You can customise by passing tailwind classes. |
| onClose | () => void | Optional | You can get callback when alert got closed. |
| role | 'alert' | 'status' | Optional | ARIA role for accessibility. |
| children | React.ReactNode | Optional | Custom content for the alert. |
Other components solving nearby problems.
- React Alert
- React Alert Component
- React Toast Notification
- React Alert Message
- React Popup Alert
- React UI Alert
- React Dismissible Alert
- Custom Alert in React
- React Alert with Hooks
- React Toast Component
- Example React Alert
- React Notification System
- React Banner Alert
- React Toast Alert
- React Modal Alert
- React Error Alert
- React Success Alert
- Styling React Alert
- React Alert Animation
- React Alert Accessibility
- Notification Component React
- Alert UI Library
- React Alert Tutorial
- Toast Notification Library
- React Snackbar Component
- Alert Design System
- React Alert TypeScript
- Mobile Alert React
- Alert Component Best Practices
- React Notification Library