PicturePreview

An image preview component with zoom, navigation, and gallery functionality

Installation

Terminal
pnpm add @choice-ui/picture-preview

Import

Component.tsx
import { PicturePreview } from "@choice-ui/picture-preview"

Basic

`PicturePreview` is a component for displaying image previews with additional metadata.
Features:
- Clean, responsive image display - File name display - Image loading indicator - Error state handling - Optimized image rendering - Support for various image formats
Usage Guidelines:
- Use for displaying image previews in galleries, file lists, or attachments - Provide both image source and file name for complete context - Consider appropriate sizing in your layout (component will adapt) - Use in conjunction with image loading or lazy loading for performance
Accessibility:
- Includes appropriate alt text based on file name - Maintains proper contrast for filename text - Supports keyboard navigation - Loading states are properly communicated to screen readers
koi-fish-lotus.jpg

With Error

WithError: Demonstrates how the component handles image loading errors.
This example shows how the PicturePreview component displays an error state when the image fails to load. It provides visual feedback to the user that there was a problem loading the image, while still displaying the filename information.
broken-image.jpg

Control Always Visible

ControlAlwaysVisible: Shows the zoom control bar always visible.
By default, the control bar only appears on hover. Setting `control.show` to "always" makes it permanently visible.
koi-fish-lotus.jpg

Control Positions

ControlPositions: Demonstrates different control bar positions.
The control bar can be positioned in any corner of the preview:
- top-left - top-right - bottom-left - bottom-right (default)
top-left
koi-fish-lotus.jpg
top-right
koi-fish-lotus.jpg
bottom-left
koi-fish-lotus.jpg
bottom-right
koi-fish-lotus.jpg

Control Disabled

ControlDisabled: Shows the preview without zoom controls.
Setting `control.enable` to false hides the control bar entirely, useful for read-only previews or when zoom functionality is not needed.
koi-fish-lotus.jpg

API reference

PicturePreviewTypeDefault
defaultText
{ error: string; fitToScreen: string; zoomIn: string; zoomOut: string; zoomTo100: string; zoomTo200: string; zoomTo50: string; }
|
undefined
-
fileName
string
|
undefined
-
onClose
(() => void)
|
undefined
-
src
string -
control
{ enable?: boolean
|
undefined; position?: "top-left"
|
"top-right"
|
"bottom-left"
|
"bottom-right"
|
undefined; show?: "always"
|
"hover"
|
undefined; }
|
undefined
-