Skip to content
Nana UI

Feedback & Status

Alert

A contextual message banner for feedback, status and important notices. Supports an optional title, a leading status icon, action buttons and a dismiss control.

View .md Download
Heads up — this is an informational alert.

The alert ships for all three targets. Pick the tab for your project — the CLI detects which you are on and serves the matching implementation.

npx @nana-tec/ui add alert

Lands as src/components/ui/alert/alert.tsx, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

import { Alert } from "@/components/ui/alert";
export function Example() {
return <Alert variant="info">Heads up — this is an informational alert.</Alert>;
}

title, icon and actions take nodes. Passing onDismiss renders the close button — the alert does not hide itself, so keep the visibility in your own state:

{shown && (
<Alert variant="danger" title="Payment failed" onDismiss={() => setShown(false)}>
Your card was declined.
</Alert>
)}

Classes you pass to the React and Svelte components are merged with tailwind-merge, so an override wins rather than fighting. See Using Tailwind.

Info alert Success alert Warning alert Danger alert Neutral alert

The React and Svelte props, read from the components’ own types:

Alert

PropTypeDefault
variantAlertVariant'info'
titleReactNode
iconReactNode
actionsReactNode
onDismiss() => void
childrenReactNode

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'>.

The attribute names, events and CSS hooks below are the Web Components reference.

Properties

PropertyAttributeTypeDefaultDescription
closableclosablebooleanfalseShow a dismiss button that closes the alert
noIconno-iconbooleanfalseHide the leading status icon
openopenbooleantrueControls visibility. Dismissing sets this to false.
titletitlestring''Optional bold heading shown above the message
variantvariantAlertVariant'info'Visual + semantic style

Events

EventDescription
nana-closeDispatched when the alert is dismissed

Slots

SlotDescription
(default)The alert message / body content
iconCustom leading icon (overrides the default variant icon)
actionsAction buttons shown beneath the message

CSS parts

PartDescription
::part(actions)The trailing actions area
::part(base)The alert container
::part(close-button)The dismiss button, when closable
::part(icon)The leading status icon
::part(message)The message body
::part(title)The title line

CSS custom properties

PropertyDescription
--nana-alert-bgCustom background colour
--nana-alert-colorCustom text colour
--nana-alert-borderCustom border colour
EventTypeDescription
nana-closeCustomEventDispatched when the alert is dismissed
SlotDescription
(default)The alert message / body content
iconCustom leading icon (overrides the default variant icon)
actionsAction buttons shown beneath the message
VariableDescription
--nana-alert-bgCustom background colour
--nana-alert-colorCustom text colour
--nana-alert-borderCustom border colour
PartDescription
baseThe alert container
iconThe leading status icon
titleThe alert title
messageThe alert message body
actionsThe action buttons container
close-buttonThe dismiss button
Explore Alert interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook