Alert
Alerts are used to communicate a state that affects a system, feature or page.
Import
import { Alert } from '@recastui/react';
Usage
Editable Example
<Alerticon={IconAlertCircle}title='Something went wrong!'color='error'description='Please check your input and try again.'/>
Variants
There are 3 variants of the alert component subtle
, solid
& outline
. The default variant is subtle
.
Editable Example
<><Alerticon={IconAlertCircle}title='Something went wrong!'color='error'description='Please check your input data and try again.'/><div className='my-4' /><Alertvariant='solid'icon={IconAlertCircle}title='Something went wrong!'color='error'description='Please check your input data and try again.'/><div className='my-4' /><Alertvariant='outline'icon={IconAlertCircle}title='Something went wrong!'color='error'description='Please check your input data and try again.'/></>
Colors
You can pass any RecastColor
tothe alert component. The default color is info
.
Editable Example
<><Alerticon={IconAlertCircle}title='Purple color'color='purple'description='Please check your input data and try again.'/><div className='my-4' /><Alertvariant='solid'icon={IconAlertCircle}title='Pink solid color'color='pink'description='Please check your input data and try again.'/><div className='my-4' /><Alertvariant='outline'icon={IconAlertCircle}title='Just a mono color'color='main'description='Please check your input data and try again.'/></>
Status Colors
The most common Alert statuses are error
, success
, info
& warning
.
Editable Example
<><Alerticon={IconAlertCircle}title='Something went wrong!'color='error'description='Please check your input data and try again.'/><div className='my-4' /><Alerticon={IconCircleCheck}title='Great success!'color='success'description='Your application has been successfully submitted. High five!'/><div className='my-4' /><Alerticon={IconInfoCircle}title='Its time to get ready!'color='info'description='Recastui is going live on April 1st. Get ready!'/><div className='my-4' /><Alerticon={IconAlertTriangle}title='Your battery is low'color='warning'description='Seems like your battery is about die, recharge now.'/></>
Accessibility
This Alert component has been designed to follow best practices for accessibility:
role='alert
is set on the root div of theAlert
component.aria-labelledby
is set to theid
of thetitle
element of the Alert component.aria-describedby
is set to theid
of thedescription
element of the Alert component.