- 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
- 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
A specimen of a font file at several sizes, one row per size, loaded under a family of its own.
Installation#
pnpm dlx shadcn@latest add @zui/font-previewThe CLI writes components/data-display/font-preview.tsx, installs Text and
Utils, and adds expo-font.
Usage#
import { FontPreview } from '@/components/data-display/font-preview';<FontPreview src={fontUrl} />The consumer places, pads and widths its wrapper; it renders one row per size, largest first, each specimen on one line that ends in an ellipsis at that width. Use it to compare a font file's weights before shipping it; for a previewed image rather than type, use Image preview.
API reference#
FontPreview#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
src | string | required |
sizes | number[] | [36, 24, 18, 14] |
children | ReactNode | 'The quick brown fox jumps over the lazy dog' |
It loads src with expo-font under a family of its own, so several previews on one screen never collide. Until
the file has loaded, and if it fails to, the specimens are drawn in the theme's font. iOS and Android load
TrueType and OpenType files; a WOFF or WOFF2 file loads on the web only.
Differences from the web#
formatis not taken: expo-font reads a file's format itself, and a device loads no@font-face.- The web's
data-slotattribute is not set; a View takes no data attributes.