Alert

A component for displaying contextual feedback messages to users

Loading...
npx shadcn@latest add https://ui.sikka.io/r/alert.json
npx shadcn@latest add https://ui.sikka.io/r/alert.json
pnpm dlx shadcn@latest add https://ui.sikka.io/r/alert.json
bunx --bun shadcn@latest add https://ui.sikka.io/r/alert.json

Overview

The Alert component displays important contextual feedback messages to users. It supports multiple severity levels, custom icons, actions, and can be configured to auto-dismiss after a specified duration.

Props

Here are the available props for the Alert component:

PropTypeDefaultDescription
severity"info" | "warning" | "error" | "success" | "none" | "hyper" | "oceanic""none"The severity level of the alert
titleReact.ReactNode-The title of the alert
textReact.ReactNode-The main content of the alert (required)
durationnumber-Duration in ms before alert auto-dismisses
direction"ltr" | "rtl""ltr"Text direction
actionsArray of action objects-Action buttons to display
persistentbooleanfalseIf true, removes the close button
iconReact.ReactNode-Custom icon to display
classNamesObject-Custom class names for sub-components
onAlertClosed() => void-Callback when alert is closed
noDestroybooleanfalseIf true, keeps alert in DOM when closed

Examples

Basic Usage

<Alert 
  title="Information"
  text="This is an informational message"
  severity="info"
/>

With Actions

<Alert
  title="Warning"
  text="Your session will expire soon"
  severity="warning"
  actions={[
    {
      label: "Extend",
      onClick: () => extendSession(),
      variant: "outline"
    }
  ]}
/>

Auto-dismissing

<Alert
  text="Operation completed successfully"
  severity="success"
  duration={3000}
/>

Custom Icon

<Alert
  title="Custom"
  text="Alert with custom icon"
  icon={<CheckCircleIcon />}
/>

Gradient Styles

<Alert
  text="Hyper style alert"
  severity="hyper"
/>

<Alert
  text="Oceanic style alert"
  severity="oceanic"
/>

On this page