Alert
- Stable
- WCAG 2.2 evidence
- RTL
An inline status message about a section or a task: tone icon, title, optional description, actions
and close button. A status region (role="status", or role="alert" when politeness="assertive") so the message is
announced when it appears (WCAG 4.1.3); the tone has its own icon and a text alternative, never colour alone (1.4.1,
1.1.1). Presentational: renders in React Server Components. The close button is a small client island. Consumer duties: message wording ("say what happened and what to do next"), the urgency (politeness), removing the
alert and moving focus in onDismiss. Use Toast for transient confirmations and Banner for page-wide notices.
import { Alert } from "@nexera-ui/react";- 5
- examples
- 9
- props
- 5
- live controls
- 1
- platform
- 11
- WCAG criteria
- 27
- blocks use it
Try every prop. Copy the code.
Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.
import { Alert } from "@nexera-ui/react";
<Alert />Examples 4
The same examples as Storybook, rendered live. Open Code to copy one.
Tones
Every Tone. Each has its own icon and a visually hidden text alternative ("Error:"), never colour alone.
import { Alert } from "@nexera-ui/react";
const tones = ["info", "success", "warning", "danger", "neutral"] as const;
export function Tones() {
return (
<div className="flex flex-col gap-4">
{tones.map((tone) => (
<Alert
key={tone}
title="Leave policy updated"
description="Review the changes before your next request."
tone={tone}
politeness="polite"
/>
))}
</div>
);
}
Dismissible
The alert appears after an event (so it is announced) and the consumer removes it in onDismiss, moving focus back to the button that triggered it.
import { useState } from "react";
import { Alert, Button } from "@nexera-ui/react";
export function Dismissible() {
const [visible, setVisible] = useState(false);
return (
<div className="flex flex-col items-start gap-4">
<Button
id="save-policy"
onPress={() => {
setVisible(true);
}}
>
Save policy
</Button>
{visible ? (
<Alert
tone="success"
title="Leave policy updated"
description="Employees see the new rules from tomorrow."
onDismiss={() => {
setVisible(false);
document.getElementById("save-policy")?.focus();
}}
/>
) : null}
</div>
);
}
Long content
Long titles, descriptions and several actions wrap instead of truncating (translation adds 30 to 40 %).
import { Alert, Button } from "@nexera-ui/react";
<Alert
title="Your leave request for the whole of next quarter is waiting for approval from two managers"
description="We will email you as soon as both managers have answered. You can still edit or withdraw the request until then."
tone="warning"
actions={
<>
<Button variant="ghost" size="sm">
Edit request
</Button>
<Button variant="ghost" size="sm">
Withdraw request
</Button>
</>
}
onDismiss={() => undefined}
/>;
Right to left
Right-to-left: the icon sits at the start (right), the close button at the end (left).
import { Alert } from "@nexera-ui/react";
<Alert
title="تم تحديث سياسة الإجازات"
description="راجع التغييرات قبل طلبك التالي."
iconLabel="معلومة"
onDismiss={() => undefined}
dismissLabel="إغلاق"
/>;
Props 9
Press "Try it" on a card to load that prop into the playground.
9 props shown
title*NexeraReactNodeWhat happened, for example "Leave policy updated". Keep it under 8 words. Wraps, never truncated.
toneNexera"info" | "success" | "warning" | "danger" | "neutral"Severity. Each tone has its own icon as well as its colour, and iconLabel names it for assistive
technology, so the severity is never conveyed by colour alone (WCAG 1.4.1).
politenessNexera"polite" | "assertive"How assistive technology announces the alert when it appears (WCAG 4.1.3): polite renders role="status"
(waits for the user), assertive renders role="alert" (interrupts; for urgent problems only). Render the alert
when the event happens; an alert that is already on the page at load is not announced.
iconLabelNexerastringText alternative of the tone icon, read before the title followed by a colon ("Error: Payment failed"). Translate it
for your locale; pass "" when the title already states the severity.
actionsNexeraReactNodeNext steps, for example <Button variant="ghost" size="sm">View details</Button>. Shown when provided:
under the text in the default layout, at the end of the row in the compact layout.
layoutNexera"default" | "compact"default stacks title, description and actions; compact is one row with the title and an action.
One row with the title and an action.
descriptionNexeraReactNodeWhat to do next, for example "Review the changes before your next request." Shown when provided, in the default layout only.
onDismissNexera() => voidShows the close button and is called without arguments when it is activated; accepts a Server Action. The alert does not hide itself: remove it in this callback, and move focus somewhere sensible (for example the heading of the section), because the focused button disappears with it.
dismissLabelNexerastringAccessible name of the close button. Translate it for your locale.
* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.
Accessible by default.
Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.
WCAG 2.2 evidence
6 direct · 5 supporting- 1.1.1Non-text ContentLevel A · tested directly
- 1.3.1Info and RelationshipsLevel A · tested directly
- 1.3.2Meaningful SequenceLevel A · supporting test
- 1.4.1Use of ColorLevel A · tested directly
- 1.4.10ReflowLevel AA · supporting test
- 1.4.12Text SpacingLevel AA · supporting test
- 2.1.1KeyboardLevel A · tested directly
- 2.4.7Focus VisibleLevel AA · supporting test
- 2.5.8Target Size (Minimum)Level AA · supporting test
- 4.1.2Name, Role, ValueLevel A · tested directly
- 4.1.3Status MessagesLevel AA · tested directly
Fits any width.
Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.
Styling hooks
Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.
data-hovereddata-pressed
<Alert className="data-hovered:opacity-90 shadow-sm" />Used in blocks
- Sign inSign in and account
- Create accountSign in and account
- Two-step verificationSign in and account
- Set a new passwordSign in and account
- Session expiredSign in and account
- Onboarding stepsOnboarding
- Profile setupOnboarding
- Invite your teamOnboarding
- Settings layoutApp shells and navigation
- Bulk actionsLists, tables and records
- Contact formForms and data entry
- Add a personForms and data entry
- Multi-step formForms and data entry
- Address and phoneForms and data entry
- Date range pickerForms and data entry
- Delete accountSettings and preferences
- Book a meetingScheduling and calendar
- CheckoutCommerce and payments
- Order summaryCommerce and payments
- Help articleMedia and content
- Mood check-inFeedback and surveys
- Rate thisFeedback and surveys
- Short surveyFeedback and surveys
- Confirm a destructive actionStates and system messages
- Maintenance and offlineStates and system messages
- Action sheetMobile patterns
- Bottom sheet pickerMobile patterns
Related components
- BannerA page-wide notice across the top of a page or app shell: tone icon, message, optional link and close button on a solid fill.
- CircularProgressShows progress as a ring with the value in the centre.
- EmptyStateExplains why a list, table or page has no content and what to do next.
- ProgressBarShows how far a task has progressed.
- ProgressStepsA segmented progress indicator for a flow with a known number of steps, such as onboarding or a form wizard: a header with "Step 2 of 5" and the step title above one segment per step.
- SpinnerSmall loading indicator.
- SpinnerLabelA spinner with a status message.
- ToastGives the components below it a toast queue through `useToast()` and renders its `ToastRegion`.