Alert
Alert shows a message inside the page, next to the content it is about. Use it for information people should see in context.
Built from the owner's alert reference (2026-10-14): five statuses, four appearances and three sizes. Beta until the matrix is in Figma and design confirms the contrast adjustments listed below. Everything on this page is implemented and tested.
Preview
Change the controls to try every supported combination. The preview uses role="none" so changing controls doesn't announce anything.
Information: What’s a space?
import { Alert, AlertAction } from '@nuton/ui'
<Alert
status="information"
size="large"
title="What’s a space?"
description="Space keeps chats, documents, and videos in one place for better organization and efficient learning."
dismissible
actions={<>
<AlertAction onClick={openSpaces}>Open spaces</AlertAction>
<AlertAction href="/help/spaces">Learn more</AlertAction>
</>}
/>Installation
Availability
@nuton/ui and @nuton/tokens are private workspace packages and aren't published yet (D4, D12). Inside the Nuton monorepo, add them as workspace dependencies.
pnpm add @nuton/ui @nuton/tokens @remixicon/reactnpm install @nuton/ui @nuton/tokens @remixicon/reactyarn add @nuton/ui @nuton/tokens @remixicon/reactimport '@nuton/tokens/tokens.css'
import '@nuton/ui/styles.css'Usage
import { Alert } from '@nuton/ui'
<Alert
title="What’s a space?"
description="Space keeps chats, documents, and videos in one place for better organization and efficient learning."
/>- Place the alert next to what it's about: at the top of a form, a lesson or a settings group.
- Keep the title short. Put the detail in the description, and one or two next steps in
actionsasAlertActions. - Pick the size by content:
xsmallorsmallfor one line (a banner, a toast),largewhen there's a description. Withoutsize, an alert with a description is large and one without is small. - Pick the appearance by emphasis:
filledfor the strongest,lightandlighterfor most in-page alerts,strokeon tinted surfaces or for toasts. - Pick the status by meaning, not colour:
errorfor something that failed,warningfor a risk,successfor a finished task,informationorneutralfor help. - For a short confirmation after an action, use a Toast. For a decision that blocks the page, use a Modal.
Variants and sizes
Five statuses (rows) in four appearances (columns), in three sizes. This is the owner's reference matrix, built with Nuton tokens.
X-small
One line, 32 tall: 16px icon, Paragraph/X Small text, Label/X Small action, radius 8.
filled
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
light
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
lighter
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
stroke
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
<Alert size="xsmall" status="error" appearance="filled" title="Insert your alert title here!"
actions={<AlertAction>Button</AlertAction>} dismissible />Small
One line, 36 tall: 20px icon, Paragraph/Small text, Label/Small action, radius 8.
filled
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
light
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
lighter
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
stroke
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
<Alert size="small" status="success" appearance="light" title="Insert your alert title here!"
actions={<AlertAction>Button</AlertAction>} dismissible />Large
Title, a description and actions under the text with a dot between them; padding 14, radius 12, close at the top end.
filled
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
light
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
lighter
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
stroke
Error: Insert your alert title here!
Success: Insert your alert title here!
Warning: Insert your alert title here!
Insert your alert title here!
Information: Insert your alert title here!
<Alert
status="warning"
appearance="lighter"
title="Insert your alert title here!"
description="Insert the alert description here. It would look better as two lines of text."
actions={<>
<AlertAction onClick={…}>Button</AlertAction>
<AlertAction href="/help">Learn more</AlertAction>
</>}
dismissible
/>Examples on this page pass role="none" so the docs don't announce them on load. In your app, leave the default role.
Colours and contrast
Every text pair is at least 4.5:1 and every icon at least 3:1. Where the reference colours fell short, code uses the next step of the same hue.
| Appearance | Background | Title · description | Icon |
|---|---|---|---|
| Filled | Strong step: red-700, green-800, orange-800, gray-600, Primary/Base (the badge rule, C47) | White · white (4.93:1 or more) | White |
| Light | State/<status>/Light | Strong-950 · gray-700 (Sub-600 is 4.33:1 on Error/Light) | Strong step (3.40:1 or more) |
| Lighter | State/<status>/Lighter (neutral: Bg/Weak-50, the Figma frame) | Strong-950 · Sub-600 (5.84:1 or more) | Strong step (4.53:1 or more) |
| Stroke | Bg/White, 1px Stroke/Soft-200 | Strong-950 · Sub-600 (6.69:1) | Strong step |
Content options
AI Tutor tip
<Alert description="Only the description, no title." />
<Alert icon={<RiSparklingLine />} title="AI Tutor tip" description="Ask for a worked example of any formula." />States and interactions
Static
Dismissible
Dismissing and focus
When the close button is pressed the alert disappears and focus would be lost. Use onDismiss to move focus somewhere sensible, such as the section heading.
Biology 101
Information: New lessons added
const headingRef = useRef<HTMLHeadingElement>(null)
<h3 ref={headingRef} tabIndex={-1}>Biology 101</h3>
<Alert
status="information"
title="New lessons added"
description="Two lessons on cell respiration are ready."
dismissible
onDismiss={() => headingRef.current?.focus()}
/>State tokens
Set on .nu-alert. Each status sets --nu-alert-strong, --nu-alert-light and --nu-alert-lighter; each appearance maps them to --nu-alert-bg, --nu-alert-border, --nu-alert-fg, --nu-alert-muted, --nu-alert-icon and --nu-alert-close; each size sets --nu-alert-radius, --nu-alert-pad-block, --nu-alert-pad-inline, --nu-alert-gap and the icon sizes.
Differences from the reference
- Status icons are the Status Badge shapes (a second cue besides colour), not the reference's placeholder glyph.
- Filled backgrounds and some icons use a stronger step of the hue so text and icons pass contrast (table above).
- The close button is a 24 × 24 target around the 16 or 20px icon (WCAG 2.5.8).
- Descriptions use Nuton's Paragraph/Small 24px line height.
Composition examples
Error after submit
An error alert at the top of a form uses role="alert" by default, so screen readers announce it straight away.
API reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
status | 'error' | 'success' | 'warning' | 'neutral' | 'information' | 'neutral' | Colour, icon, status word and default role. |
appearance | 'filled' | 'light' | 'lighter' | 'stroke' | 'lighter' | Emphasis: solid, tint, pale tint, or white with a border. |
size | 'xsmall' | 'small' | 'large' | large with a description, else small | xsmall and small are one line; large adds the description and puts actions under it. |
title | ReactNode | — | The message. Label/Small in large; regular weight in the one-line sizes. |
description | ReactNode | — | Supporting text (large). children is used when omitted. In one-line sizes it becomes the line when there is no title. |
actions | ReactNode | — | AlertActions. Large: under the text with a dot between. One-line: at the end of the line. |
icon | ReactNode | false | — | Replaces the status icon; false hides it. Decorative (aria-hidden). |
statusLabel | string | false | — | Word read before the title by screen readers. Defaults: Information, Success, Warning, Error; none for neutral. |
dismissible | boolean | false | Shows the close button. The alert hides itself when pressed. |
onDismiss | () => void | — | Called after the alert hides. Move focus here. |
dismissLabel | string | 'Dismiss' | Accessible name of the close button. |
role | 'alert' | 'status' | 'none' | error → 'alert', else 'status' | Live-region role. none renders no role, for static notices. |
…div props | HTMLAttributes<HTMLDivElement> | — | className, id and other attributes go to the container. The ref points at it. |
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | — | Renders a link; without it, a button. |
childrenrequired | ReactNode | — | The action label, e.g. “Learn more”. |
…button or anchor props | ButtonHTMLAttributes | AnchorHTMLAttributes | — | onClick, target and other attributes. Text takes the alert colour; it underlines on hover. |
Accessibility
Keyboard
| Key | Behaviour |
|---|---|
| Tab | Moves to the actions, then the close button |
| Enter / Space | Activates the focused action or close button |
Screen readers
Errors use role="alert" and are announced at once; other statuses use role="status" and are announced politely. Only content that changes after the page loads is announced. A hidden status word ("Warning:") comes before the title; the icon is hidden.
Focus
The alert itself never takes focus. The close button has a 2px primary ring. After dismissing, move focus with onDismiss.
Contrast and colour
Every text pair is 4.5:1 or more and every icon 3:1 or more in all 60 combinations (see Colours and contrast). Status isn't shown by colour alone: the icon shape and the hidden status word carry it too. In forced-colours mode the container gets a system border.
Touch and pointer
The close button is a 24 × 24 target (WCAG 2.5.8). Actions are 24 tall in large alerts; in the one-line sizes they follow the line height and are spaced from the close button.
You must: write a title or description that makes sense alone, and move focus when a dismissed alert held it.
Figma mapping
| Figma layer | Figma value | Code |
|---|---|---|
| Reference rows | Error, success, warning, gray, blue | status: error, success, warning, neutral, information |
| Reference columns | Solid, tint, pale tint, white with border | appearance: filled, light, lighter, stroke |
| Reference blocks | Small one line, larger one line, with description | size: xsmall, small, large |
| "Button · Learn More" | Text actions with a dot | actions with AlertAction |
| Figma 3806:36330 | Bg/Weak-50, information-fill, Label/Small · Paragraph/Small | neutral + lighter + large |
Guidelines and related components
Use Alert for
- Help or a status that belongs to one part of the page
- Errors that stop a form or a sync
- Warnings about limits, like a trial ending
Don't use Alert for
- Short confirmations after an action (use Toast)
- Decisions that must be made now (use Modal)
- Field errors (use the Field error text)
Do and don't
Error: We couldn’t sync your notes
Error: Error
Success: Course completed
Error: New feature: AI Tutor
Warning: Your trial ends in 3 days
Warning: Your trial ends in 3 days