- 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 frame that shows an image contained within it, over a checkerboard so transparent pixels read clearly.
Installation#
pnpm dlx shadcn@latest add @zui/image-previewThe CLI writes components/data-display/image-preview.tsx, installs Icon
and Utils, and adds lucide-react-native and react-native-svg.
Usage#
import { ImagePreview, ImagePreviewImage } from '@/components/data-display/image-preview';<ImagePreview>
<ImagePreviewImage src={src} alt="Logo" />
</ImagePreview>It fills the space it is given, so size its wrapper rather than the frame itself. For a font file's specimen instead of an image, use Font preview.
Composition#
ImagePreview
`-- ImagePreviewImageAPI reference#
ImagePreview#
Takes every prop of React Native's View. A frame on the background colour with a checkerboard of the muted
colour drawn under its children, hidden from a screen reader and from touches.
ImagePreviewImage#
Takes every prop of React Native's Image, src included. It fills the frame and draws the image centred and
scaled down to fit, never up (resizeMode="center", which a caller may override). It defaults alt to empty,
which hides it from a screen reader as decorative; give it real text when the image conveys information, and it
is announced as an image of that name.
Differences from the web#
- The checkerboard is an svg pattern laid under the image; React Native draws no CSS gradient, which the web's
bg-checkerboardis, so the item adds no utility to the app's CSS. - React Native's Image draws no svg file; preview one with
react-native-svginstead. - The web's
data-slotattributes are not set; a View takes no data attributes.