Components
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Dialog
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Label
- Menu
- Meter
- Number Field
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Slider
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Resources
Alert
A callout for displaying important information.
Heads up!
Describe what can be done about it here.
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<Alert>
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
Installation
pnpm dlx shadcn@latest add https://coss.com/ui/r/alert.json
Usage
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert>
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
You can add components and dependencies to your app using the cli.
</AlertDescription>
</Alert>
Examples
With Icon
Heads up!
Describe what can be done about it here.
import { InfoIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertWithIcon() {
return (
<Alert>
<InfoIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
With Icon and Action Buttons
Heads up!
Describe what can be done about it here.
import { InfoIcon } from "lucide-react"
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
export function AlertWithIconAction() {
return (
<Alert>
<InfoIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
<AlertAction>
<Button variant="ghost" size="xs">
Dismiss
</Button>
<Button size="xs">Ok</Button>
</AlertAction>
</Alert>
)
}
Info Alert
Heads up!
Describe what can be done about it here.
import { InfoIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertInfo() {
return (
<Alert variant="info">
<InfoIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
Success Alert
Heads up!
Describe what can be done about it here.
import { CircleCheckIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
export function AlertSuccess() {
return (
<Alert variant="success">
<CircleCheckIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
Warning Alert
Heads up!
Describe what can be done about it here.
import { TriangleAlertIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertWarning() {
return (
<Alert variant="warning">
<TriangleAlertIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
Error Alert
Heads up!
Describe what can be done about it here.
import { CircleAlertIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertWarning() {
return (
<Alert variant="error">
<CircleAlertIcon />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
Describe what can be done about it here.
</AlertDescription>
</Alert>
)
}
Comparing with shadcn
New Variants
We've added new colored variants for better semantic meaning:
Variant | Description |
---|---|
info | Displays an info alert (blue) |
success | Displays a success alert (green) |
warning | Displays a warning alert (yellow) |
error | Displays a error alert (red) |
Ensure you have the following variables imported in your CSS file:
--destructive-foreground
--info
--info-foreground
--success
--success-foreground
--warning
--warning-foreground