Krizaka UI
Krizaka UI
ComponentsMedia

Image viewer

Images full screen on black: pinch and double tap to zoom, swipe between images, swipe down to close.

Web · ✗ to buildMobile · ✓Desktop · ✗ to buildBetaMedia
Domain
Media
Support level
Beta
Size
Not measured
Who uses it
No live product imports it yet
Image viewer — A gallery, as React Native renders it

“A gallery”, its React Native story at a phone's width — the same code on iOS and Android.

Mobile only — React Native, from @krizaka/ui/native. Beta: its API may still change in a minor version.

  • Web · ✗ to build. The web galleries need a full-screen viewer too. issue #279
  • Desktop · ✗ to build. The Mac app renders the web's viewer once it exists. issue #279

Why it is here. the native apps: Verikora and Folioviv mobile, Sovkora mobile: full-screen photos of a profile or a gallery.

When to use

  • The photos of a post or a message, opened full screen.
  • A creator's gallery.

When not to use

  • For a video.Use instead: Video player
  • To crop an image before upload.

Installation

Install

npx expo install react-native-svg
npm install @krizaka/ui

Import

import { ImageViewer, prefetchNeighbours } from "@krizaka/ui/native";

Wrap the app once in ThemeProvider from @krizaka/ui/native: every component reads its colour roles.

Examples

React Native has no live preview on the web: each example shows the screenshot of its story, tested in both themes, and the code to copy.

Three photos, the first one open, its caption under it.

Image viewer — A gallery, as React Native renders itImage viewer — A gallery, as React Native renders it

Props

Images full screen, on black: pinch to zoom (to 4×), double tap to zoom in and out, drag a zoomed image, swipe left and right between images, swipe down to close. Screen readers get the image's words, its position, and the close button; their swipes move between images (accessibility actions).

PropTypeDefaultDescription
closeLabelrequiredstring—The close button's words (“Close”) — passed translated.
imagesrequiredreadonly ViewerImage[]—The images, in order.
indexrequirednumber | null—The image open (its index); null closes the viewer.
onIndexChangerequired(index: number | null) => void—Called when the person moves to another image or closes the viewer (null).
positionLabel((position: number, total: number) => string)(n, total) => `${n} / ${total}`The position for screen readers and the counter: (n, total) => "2 of 5".

Accessibility

  • The image is named by its words and its position (“2 of 5”); swipes of the screen reader move between images.
  • The close button is named by closeLabel; the escape gesture closes it.

Best practices

  • Give every image its words (alt); a caption when it adds something.
  • Call prefetchNeighbours so the next swipe shows at once.

Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page