Alert

Alerts communicate persistent inline feedback with a clear semantic tone, concise text, and accessible announcement options when content changes dynamically.

Overview and decision boundary

Use Alert for inline feedback that stays in the page flow until the content changes or the consumer dismisses it.

Do not use Alert as a toast replacement or dismiss required information without a durable alternative.

Update available
A new version of the application is available. Refresh to get the latest features and fixes.
import { Info, X } from "@nerio-ui/adapters/icons";import { Alert } from "@nerio-ui/ui";import { Button } from "@nerio-ui/ui/client";<Alert  icon={Info}  title="Update available"  action={<Button size="sm">Refresh</Button>}  closeAction={    <Button      aria-label="Close alert"      icon={X}      size="sm"      tooltip={false}      variant="secondary"    />  }>  A new version of the application is available. Refresh to get the latest features and fixes.</Alert>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm exec nerio add alertimport { Circle } from '@nerio-ui/adapters/icons';import { Alert } from '@nerio-ui/ui';

Usage

import { Circle } from '@nerio-ui/adapters/icons';import { Alert } from '@nerio-ui/ui';<Alert tone="info" title="Invite sent" icon={Circle}>Collaborators will receive an email shortly.</Alert>

Variants

ToneUse
neutralLow-emphasis status or message that does not need a semantic emphasis.
infoInformational context that should remain calm and visible in the page flow.
successPositive completion or validation feedback.
warningAn issue that needs attention without blocking the entire flow.
dangerAn error, destructive outcome, or blocking state.

Anatomy

SlotPurpose
rootInline feedback region that applies tone and spacing tokens.
iconOptional decorative icon rendered through the Nerio icon adapter.
contentContainer for the title and descriptive content.
titleOptional short summary that establishes the message hierarchy.
descriptionBody content that explains the state or provides a next step.
actionOptional actions rendered below the description.
closeOptional consumer-owned icon button that dismisses the alert.

States

StateBehavior
StaticNo live-region semantics are applied by default.
Status updateUse role="status" for a dynamic, non-urgent update.
Urgent updateUse role="alert" only when a dynamic error needs immediate announcement.

Motion

  • State changes should use shared motion tokens and preserve reduced-motion behavior.

Accessibility

  • Static inline alerts do not announce by default; pass role="status" or role="alert" only for dynamic updates that need announcement.
  • Tone is supported by text; do not rely on color alone.
  • Optional icons must pass through the Nerio icon adapter.

Review the shared responsibility and evidence boundaries in the Accessibility foundation alongside this component-specific contract. Use the Spacing & layout foundation for shared density, wrapping, overflow, reflow, and component-versus-product ownership guidance. The Color foundation, Typography foundation, and Localization foundation define the shared visual-role, text-resilience, direction, and locale boundaries used by component examples.

API

PropValuesPurpose
toneneutral | info | success | warning | dangerSelects the semantic feedback treatment.
titleReactNodeAdds a concise summary above the description.
iconIconComponentRenders a decorative icon through the Nerio icon adapter.
actionReactNodeAdds one or more actions below the description.
closeActionReactNodeAdds a consumer-owned close control in the trailing slot.
rolestatus | alertOpt into announcement semantics only for dynamic content.
childrenReactNodeProvides the descriptive message content.
classNamestringExtends the root without replacing component tokens.

Implementation contract

ContractValue
Registry itemalert installs five source files into the configured components directory.
Base UINo interactive primitive required.
Registry dependenciesNone.
Package dependenciesclsx, react

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Alert is a flat muted surface: semantic color stays on the icon while title and description remain neutral.
  • Use the message text and optional icon together so status never depends on color alone.

Do / do not

Do
Use Alert for inline validation summaries, persistent notices, and contextual feedback. Keep actions below the description.
Do not
Use Alert as a toast replacement or make required information disappear without a durable alternative.

Tokens

GroupTokensControls
Layout--n-alert-gap / --n-alert-padding / --n-alert-radiusControls compact spacing and shape.
Surface--n-alert-border-width / --n-alert-border / --n-alert-background / --n-alert-shadowKeeps persistent feedback flat, muted, and borderless by default.
Emphasis--n-alert-title-color / --n-alert-icon-colorKeeps the title neutral and applies semantic emphasis only to the icon.
Icon--n-alert-icon-sizeControls the optional icon scale.
Semantic tones--n-color-status-info / success / warning / dangerControls semantic icon emphasis without changing the neutral text hierarchy.