shadcn-remix
GitHub

Alert

Displays a callout for user attention.

import { css } from 'remix/component'

import { Alert, AlertDescription, AlertTitle } from '#app/ui/alert.tsx'
import { AlertCircleIcon, CheckCircle2Icon, PopcornIcon } from '#app/ui/icons.tsx'

export function AlertDemo() {
import { css } from 'remix/component'

import { Alert, AlertDescription, AlertTitle } from '#app/ui/alert.tsx'
import { AlertCircleIcon, CheckCircle2Icon, PopcornIcon } from '#app/ui/icons.tsx'

export function AlertDemo() {
  return () => (
    <div
      mix={css({
        display: 'grid',
        width: '100%',
        maxWidth: '36rem',
        alignItems: 'start',
        gap: '1rem',
      })}
    >
      <Alert>
        <CheckCircle2Icon />
        <AlertTitle>Success! Your changes have been saved</AlertTitle>
        <AlertDescription>This is an alert with icon, title and description.</AlertDescription>
      </Alert>
      <Alert>
        <PopcornIcon />
        <AlertTitle>This Alert has a title and an icon. No description.</AlertTitle>
      </Alert>
      <Alert variant="destructive">
        <AlertCircleIcon />
        <AlertTitle>Unable to process your payment.</AlertTitle>
        <AlertDescription>
          <p>Please verify your billing information and try again.</p>
          <ul
            mix={css({
              listStylePosition: 'inside',
              listStyleType: 'disc',
              fontSize: '0.875rem',
              lineHeight: 'calc(1.25 / 0.875)',
            })}
          >
            <li>Check your card details</li>
            <li>Ensure sufficient funds</li>
            <li>Verify billing address</li>
          </ul>
        </AlertDescription>
      </Alert>
    </div>
  )
}

Installation

$ pnpm dlx shadcn@latest add https://www.shadcn-remix.com/r/alert.json

Usage

import { Alert, AlertDescription, AlertTitle } from '#app/ui/alert.tsx'
import { InfoIcon } from '#app/ui/icons.tsx'
<Alert>
  <InfoIcon />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components and dependencies to your app using the cli.
  </AlertDescription>
</Alert>

Composition

Use the following composition to build an Alert. Place an icon as the first child to get the icon column:

Alert
├── Icon
├── AlertTitle
└── AlertDescription

Examples

Destructive

Use variant="destructive" to create a destructive alert.

import { Alert, AlertDescription, AlertTitle } from '#app/ui/alert.tsx'
import { AlertCircleIcon } from '#app/ui/icons.tsx'

export function AlertDestructive() {
  return () => (
    <Alert variant="destructive">
import { Alert, AlertDescription, AlertTitle } from '#app/ui/alert.tsx'
import { AlertCircleIcon } from '#app/ui/icons.tsx'

export function AlertDestructive() {
  return () => (
    <Alert variant="destructive">
      <AlertCircleIcon />
      <AlertTitle>Error</AlertTitle>
      <AlertDescription>Your session has expired. Please log in again.</AlertDescription>
    </Alert>
  )
}

API Reference

Alert

Displays a callout for user attention. Renders a <div role="alert">.

PropTypeDefault
variant"default" | "destructive""default"
mixMixValue-

AlertTitle

The title of the alert.

PropTypeDefault
mixMixValue-

AlertDescription

The description or content of the alert.

PropTypeDefault
mixMixValue-