- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
Installation#
pnpm dlx shadcn@latest add @force-ui-svelte/alert
Usage#
<script lang="ts">
import * as Alert from "$lib/components/ui/alert/index.js";
</script><Alert.Root>
<Alert.Title>Heads up!</Alert.Title>
<Alert.Description>
You can add components and dependencies to your app using the cli.
</Alert.Description>
<Alert.Action>
<button>Enable</button>
</Alert.Action>
</Alert.Root>Composition#
Use the following composition to build an Alert:
Alert.Root
├── Icon
├── Alert.Title
├── Alert.Description
└── Alert.ActionExamples#
Basic#
A basic alert with an icon, title and description.
Destructive#
Use variant="destructive" to create a destructive alert.
Status Variants#
Use variant="warning", variant="success", or variant="info" for semantic status alerts.
Action#
Use Alert.Action to add a button or other action element to the alert.
Custom Colors#
You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert.Root component.
API Reference#
Alert.Root#
The Alert.Root component displays a callout for user attention.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "warning" | "success" | "info" | "default" |
Alert.Title#
The Alert.Title component displays the title of the alert.
| Prop | Type | Default |
|---|---|---|
class | string | - |
Alert.Description#
The Alert.Description component displays the description or content of the alert.
| Prop | Type | Default |
|---|---|---|
class | string | - |
Alert.Action#
The Alert.Action component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.
| Prop | Type | Default |
|---|---|---|
class | string | - |