GitHubGitHub
← All components
Feedback / component

Alert

An inline notice in four tones with an optional icon, title, body, and trailing action slot.

InfoSuccessWarningDangerWith action

Scheduled maintenance

api-gateway will be read-only on Sunday from 01:00 to 02:00 UTC.

Invoice sent

Invoice INV-2032 was emailed to ana@example.com.
<Alert tone="warning" title="Quota almost reached">  api-gateway is at 92% of its monthly request quota.</Alert>

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { Alert } from '@chanrg/4ui';<Alert tone="warning" title="Quota almost reached">  api-gateway is at 92% of its monthly request quota.</Alert>

With action

The action slot sits outside the text column, so a single next step stays on the same line as the notice.

<Alert tone="warning" title="Two projects need review">  Review them before the billing period closes.  {#snippet action()}<Button size="sm" variant="secondary">Review</Button>{/snippet}</Alert>

API reference

Props

PropTypeDefaultDescription
toneinfo | success | warning | dangerinfoSemantic colour treatment, and whether the notice interrupts.
titlestringBold first line.
iconSnippetLeading glyph, tinted with the tone and hidden from assistive technology.
children / actionSnippetExplanatory body and a trailing control cluster.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.
--4ui-info / --4ui-successTone colour for the calm variants.
--4ui-warning / --4ui-dangerTone colour for the variants that interrupt.

Accessibility

  • Warning and danger render role="alert" and interrupt; info and success are read in document order like any other block.
  • The icon is decorative — the tone is always carried by the title and body text.

Dependencies

No runtime component dependencies.