Components
- 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
- Direction
- 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
- Toast
- Toggle
- Toggle Group
- Tooltip
- Typography
Get Started
Payment successful
Your payment of $29.99 has been processed. A receipt has been sent to your email address.
New feature available
We've added dark mode support. You can enable it in your account settings.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { CheckCircle2Icon, InfoIcon } from "lucide-react"
安装
pnpm dlx shadcn@latest add alert
用法
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"<Alert>
<InfoIcon />
<AlertTitle>注意!</AlertTitle>
<AlertDescription>
你可以使用 CLI 向应用中添加组件和依赖。
</AlertDescription>
<AlertAction>
<Button variant="outline">Enable</Button>
</AlertAction>
</Alert>示例
基础
一个带图标、标题和描述的基础提示。
Account updated successfully
Your profile information has been saved. Changes will be reflected immediately.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { CheckCircle2Icon } from "lucide-react"
危险
使用 variant="destructive" 创建危险提示。
Payment failed
Your payment could not be processed. Please check your payment method and try again.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { AlertCircleIcon } from "lucide-react"
操作
使用 AlertAction 为提示添加按钮或其他操作元素。
Dark mode is now available
Enable it under your profile settings to get started.
import {
Alert,
AlertAction,自定义颜色
你可以通过给 Alert 组件添加自定义类,例如 bg-amber-50 dark:bg-amber-950,来定制提示颜色。
Your subscription will expire in 3 days.
Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { AlertTriangleIcon } from "lucide-react"
RTL
要在 shadcn/ui 中启用 RTL 支持,请参见 RTL 配置指南。
تم الدفع بنجاح
تمت معالجة دفعتك البالغة 29.99 دولارًا. تم إرسال إيصال إلى عنوان بريدك الإلكتروني.
ميزة جديدة متاحة
لقد أضفنا دعم الوضع الداكن. يمكنك تفعيله في إعدادات حسابك.
"use client"
import * as React from "react"API 参考
Alert
Alert 组件用于显示吸引用户注意的提示块。
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "default" |
AlertTitle
AlertTitle 组件用于显示提示的标题。
| Prop | Type | Default |
|---|---|---|
className | string | - |
AlertDescription
AlertDescription 组件用于显示提示的描述或内容。
| Prop | Type | Default |
|---|---|---|
className | string | - |
AlertAction
AlertAction 组件会显示一个操作元素(例如按钮),并绝对定位在提示框右上角。
| Prop | Type | Default |
|---|---|---|
className | string | - |