Alert

A prominent message that stays on the page. Keeps the colour system, and picks its ARIA role from severity — a destructive alert interrupts, the rest wait their turn.

src/components/ui/alert.tsx

About

From the component's own source, where it was written.

A prominent message that stays on the page.

Like Badge, an alert is meant to be noticed, so it keeps the colour system. role follows severity: a destructive alert is announced immediately, the rest are announced when the user gets to them.

Install

npx astralyx-ui add alert

Usage

import { Alert } from '@/components/ui/alert'

<Alert color="amber" icon={<AlertTriangle />} title="Quota almost reached">
  You have used 92% of your monthly builds.
</Alert>

Composer

Change the props and the source below follows.

Quota almost reached
You have used 92% of your monthly builds.
Props
tsx
<Alert
  icon={<Info />}
  title="Quota almost reached"
>
  You have used 92% of your monthly builds.
</Alert>

Examples

Severities

Variants

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

Alert

A prominent message that stays on the page.

Extends Omit<ComponentProps<'div'>, 'color' | 'title'>.

PropTypeDefaultDescription
color'neutral' | 'blue' | 'violet' | 'cyan' | 'green' | 'amber' | 'rose' | 'destructive''neutral'Named colour set. destructive also switches role to "alert".
variant'default' | 'outline' | 'solid''default'Tinted panel, outline, or solid fill.
size'sm' | 'default'——
iconReactNode—Leading icon, aligned to the first line of the title.
titleReactNode—Bold first line. Children become the body.
tintstring—Any CSS colour, used instead of a named set.

AlertTitle

Extends ComponentProps<'div'>.

AlertDescription

Extends ComponentProps<'div'>.

Functions

FunctionSignatureDescription
alertVariants(props?: { variant?: 'default' | 'outline' | 'solid'; color?: 'neutral' | 'blue' | 'violet' | 'cyan' | 'green' | 'amber' | 'rose' | 'destructive'; size?: 'sm' | 'default' }) => stringA prominent message that stays on the page.

Types

TypeDefinitionDescription
ColorSet
keyof typeof colorSet
—