Get started
Forms
- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
Display
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
Layout
Installation#
bash
pnpm dlx shadcn@latest add @zui/alertThe CLI writes components/ui/alert.tsx, installs Text,
Icon and Utils, and adds class-variance-authority.
Usage#
tsx
import { CircleAlert } from 'lucide-react-native';
import { Alert, AlertAction, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import { Icon } from '@/components/ui/icon';
import { Text } from '@/components/ui/text';tsx
<Alert variant="destructive">
<Icon as={CircleAlert} />
<AlertTitle>Payment failed</AlertTitle>
<AlertDescription>Your card was declined.</AlertDescription>
<AlertAction>
<Button size="xs" variant="outline">
<Text>Update</Text>
</Button>
</AlertAction>
</Alert>API reference#
Alert#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
variant | 'default' | 'destructive' | 'default' |
It carries the alert role. An Icon placed as a direct child is drawn at 16px beside the title and
description, in the colour of the variant's text. destructive draws the title, the description and the
icon in the destructive colour.
AlertTitle, AlertDescription#
Each takes every prop of Text. The title is the medium-weight line, and the description is muted, or destructive in a destructive Alert.
AlertAction#
Takes every prop of React Native's View. It is pinned to the top right of the Alert, and the Alert's
text keeps clear of it.
Differences from upstream#
- Upstream lays the alert out as a grid that puts an icon in a first column. Neither engine draws a grid, so the native Alert finds an Icon among its direct children and sets it in a row beside a column holding the rest. Pass the Icon, the title, the description and the action as direct children for that to work.
- Upstream nudges the icon 2px down to line up with the title. The native icon sits at the top of the row.
- Upstream's alert is a live region that a screen reader reads as soon as it appears. React Native's
alertrole names the box but does not announce it, and the box is not grouped into one element, so a screen reader still reaches its action. text-balanceon the description has no React Native counterpart and is dropped.