ZUI

Search documentation

Find a page or a heading.

Image preview

A frame that shows an image contained within it, over a checkerboard so transparent pixels read clearly.

Installation

bash

The CLI writes components/data-display/image-preview.tsx, installs Icon and Utils, and adds lucide-react-native and react-native-svg.

Usage

tsx
tsx

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

text

API 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-checkerboard is, so the item adds no utility to the app's CSS.
  • React Native's Image draws no svg file; preview one with react-native-svg instead.
  • The web's data-slot attributes are not set; a View takes no data attributes.