Beta

Search Documentation

Search through documentation pages

Components

Alert

Displays a callout message to attract user attention.

Preview

'use client';

import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert';
import { Button } from '@/registry/san-francisco/ui/button';

export default function AlertDemo() {
  return (
    <Alert className="max-w-sm">
      <AlertTitle>Heads up!</AlertTitle>
      <AlertDescription>You can add components to your app using the CLI.</AlertDescription>
    </Alert>
  );
}

Installation

bun
bunx shadcn@latest add @sft-ui/alert

Variants

'use client';

import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert';
import { Button } from '@/registry/san-francisco/ui/button';

export default function AlertDemoVariants() {
  return (
    <>
      <Alert variant="default" className="max-w-sm">
        <AlertTitle>Default</AlertTitle>
        <AlertDescription>This is a default alert.</AlertDescription>
      </Alert>
      <Alert variant="destructive" className="max-w-sm">
        <AlertTitle>Error</AlertTitle>
        <AlertDescription>Something went wrong.</AlertDescription>
      </Alert>
    </>
  );
}

With Action

'use client';

import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/registry/san-francisco/ui/alert';
import { Button } from '@/registry/san-francisco/ui/button';

export default function AlertDemoWithAction() {
  return (
    <Alert className="max-w-sm">
      <AlertTitle>Update available</AlertTitle>
      <AlertDescription>A new version is ready to install.</AlertDescription>
      <AlertAction>
        <Button variant="outline" size="sm">
          Update
        </Button>
      </AlertAction>
    </Alert>
  );
}

API Reference

Alert

The root alert container with role="alert".

PropTypeDefaultDescription
variant"default" | "destructive""default"The visual style of the alert.
classNamestringAdditional CSS classes to apply.

All standard HTML div attributes are supported.

AlertTitle

The heading text of the alert.

AlertDescription

The body text of the alert.

AlertAction

An absolutely positioned container (top-right) for action elements like a dismiss button.