Alert
StablePersistent in-page notification banner. Alert stays visible until dismissed — unlike Toast which auto-dismisses. The danger variant uses role='alert' for immediate screen reader announcement.
FeedbackPersistentVhyxSeal
Interactive example
Beta feature
Dismissible alert — click × to dismiss
Import
tsx
import { Alert } from '@vhyxui/react'Variants
Five semantic variants. danger uses role='alert' (assertive). All others use role='status' (polite).
Changes saved
Storage low
Payment failed
New version available
All 5 variants
States
Done
Dismissible
Custom icon
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'success' | 'warning' | 'danger' | 'info' | 'default' | Semantic variant controlling color and icon. |
title | string | — | Optional bold title rendered above the message. |
icon | React.ReactNode | — | Icon override. Each variant has a default icon. |
dismissible | boolean | false | Shows a dismiss (×) button. |
onDismiss | () => void | — | Called when the dismiss button is clicked. |
contract | Partial<ComponentContract> | — | VhyxSeal contract override. |
className | string | — | Additional CSS classes. |
Also accepts all standard HTMLDivElement attributes.
Accessibility
-
dangervariant usesrole="alert",aria-live="assertive"— announced immediately. - All other variants use
role="status",aria-live="polite"— announced at next opportunity. - Fade-in on mount only — no exit animation (Alert persists until explicitly dismissed).
- Dismiss button has
aria-label="Dismiss". - Unlike Toast, Alert is persistent — suitable for important information that must not auto-dismiss.
Keyboard navigation
| Key | Action |
|---|---|
| Tab | Move focus to the dismiss button (when dismissible=true). |
| EnterorSpace | Activate the dismiss button. |
Agent contract
Default VhyxSeal contract shipped with every Alert.
Default contract
{
"type": "display",
"intent": "display-alert",
"description": "Displays a persistent contextual alert message to the user",
"requires": [],
"requiredPermissions": [],
"consequence": "None — display only. Persists until dismissed.",
"affects": [],
"reversible": false,
"safetyLevel": "low",
"requiresConfirmation": false,
"destructive": false,
"contractVersion": "0.0.1",
"fingerprint": "vhyxs_0cc4bc1e"
}Theming
Override these CSS tokens to theme Alert.
--vhyx-color-*-subtleVariant background colors
--vhyx-color-*Variant border/icon colors
--vhyx-color-*-textVariant text colors
--vhyx-radius-mdBorder radius
--vhyx-duration-normalFade-in animation duration
--vhyx-easing-decelerateEntry easing
Examples
Form validation summary
Please fix the following errors
Danger alert with error list
Conditional alert after action
tsx
{saveError && (
<Alert
variant="danger"
title="Save failed"
dismissible
onDismiss={() => setSaveError(null)}
>
{saveError.message}
</Alert>
)}