Skip to content

Alert

import { Alert } from 'yarcl';
Trial ends in 3 days
Add a payment method to keep your projects.
Your changes were saved.
Payment failed
The card was declined.
Outline variant
<Alert
color="warning"
title="Trial ends in 3 days"
icon={<InfoIcon />}
action={<Button size="sm" color="warning">Upgrade</Button>}
onDismiss={() => setOpen(false)}
>
Add a payment method to keep your projects.
</Alert>

For messages that come and go, use Toast.

An alert that’s on the page when it loads shouldn’t interrupt screen readers, so it has no live role by default. When an alert appears in response to something, set live: 'polite' (role="status") or 'assertive' (role="alert").

PropTypeDefaultDescription
actionReactNodeActions shown after the text, e.g. a Button or Link.
colorColorconfigconfig.defaults.colorSemantic color, from the colors config.
iconReactNodeIcon shown before the text.
live'assertive' | 'polite'Announces the alert when it appears: 'polite' (role="status") or 'assertive' (role="alert"). Leave unset for messages present on page load.
onDismiss() => voidShows a dismiss button. Called when it is pressed; hide the alert in response.
radiusRadiusconfigconfig.defaults.radiusCorner radius, from the radii config.
titleReactNodeBold first line.
variantVariantconfigconfig.defaults.softVariantStyle recipe, from the variants config.