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
A lucide icon chosen for a file's type from its extension, hidden from screen readers unless given an aria-label.
Installation#
bash
pnpm dlx shadcn@latest add @zui/file-type-iconThe CLI writes components/data-display/file-type-icon.tsx and lib/file-type.ts, installs
Icon, and adds lucide-react-native.
Usage#
tsx
import { FileTypeIcon } from '@/components/data-display/file-type-icon';tsx
<FileTypeIcon name="run.py" className="text-muted-foreground size-4" />It is hidden from a screen reader, so pair it with the visible file name, or give it an aria-label where it
stands alone, which makes it an image of that name.
API reference#
FileTypeIcon#
Takes every prop of Icon except as, plus:
| Prop | Type | Default |
|---|---|---|
name | string | required |
Draws the lucide-react-native icon name maps to by its extension, through Icon, so its classes size and
colour it: code, data, image, font, audio, video, archive and text files each have their own, and any other
extension a generic file. lib/file-type.ts exports the mapping as fileTypeIcon(name).
Differences from the web#
- The web's
data-slotattribute is not set; an svg on a device takes no data attributes.