Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

ImageViewer

image-viewer

Opens images in a full-screen viewer with anchored zoom, panning, navigation, and thumbnails.

Usage

Controlled usage

open / index are all controlled; click the trigger button to set open=true to open full screen Lightbox, support wheel zoom, double-click 1x/2x, ← → Turn page, Esc close.

tsx
const [open, setOpen] = useState(false);
const [index, setIndex] = useState(0);

<>
  <button onClick={() => { setIndex(0); setOpen(true); }}>
    Open viewer
  </button>
  <ImageViewer
    open={open}
    onOpenChange={setOpen}
    images={[
      { src: "/a.jpg", alt: "A", caption: "Description A" },
      { src: "/b.jpg", alt: "B", caption: "Description B" },
    ]}
    index={index}
    onIndexChange={setIndex}
  />
</>

Single picture (no page turning)

images When there is only one image, the left and right page buttons and bottom thumbnail bar are not rendered, only zoom/close is retained.

tsx
<ImageViewer
  open={open}
  onOpenChange={setOpen}
  images={[{ src: "/poster.jpg", alt: "Poster", caption: "Activity Main Visual" }]}
  index={0}
  onIndexChange={() => {}}
/>

When to use

Use ImageViewer for fullscreen album, work-photo, or attachment inspection. Use [Sparkline] for an inline trend or [LiveProductCard] for commerce content.

Import

ts
import { ImageViewer } from "@hulianui/ui"

Props

NameTypeDefaultDescription
open*boolean-Controlled visibility.
images*ImageViewerImage[]-{src, alt?, caption?} images.
index*number-Controlled current image index.
lensboolean | ImageViewerLensConfigfalseEnables hover magnifier lens inside the viewer at 1x scale (toggle via top-bar button or L key; accepts { zoom?: number; size?: number; defaultEnabled?: boolean }).
classNamestring-Panel class name.

Events

EventTypeDescription
onOpenChange*(open: boolean) => voidClose request from Escape, overlay, or close control.
onIndexChange*(index: number) => voidPaging request from controls, keyboard, or thumbnails.

Example

tsx
const [open, setOpen] = useState(false);
const [index, setIndex] = useState(0);
<ImageViewer open={open} onOpenChange={setOpen}
  images={[{ src: "/a.jpg", alt: "A", caption: "Description" }, { src: "/b.jpg", alt: "B" }]}
  index={index} onIndexChange={setIndex} />

Usage notes

  • Both open and index are controlled; write callback values to state.
  • Scale and offset reset when index or open changes and should not be cached externally.
  • Only the current large image renders. Reset index to the intended thumbnail before opening.
  • Wheel events are captured across the whole overlay (#223): scrolling or trackpad pinching (ctrl + wheel) over the top bar, the stage, or the arrows is preventDefaulted, otherwise a pinch leaks to the browser and zooms the entire host page (sidebar and tables scale and shift along, which looks as if the component applied its transform to the wrong element). The one exception is the thumbnail strip: plain wheel passes through there so the strip can scroll horizontally, and only the pinch is caught. When the pointer sits outside the stage, the zoom anchor falls back to the stage center.
  • Built-in accessibility labels remain Chinese at runtime: "\u5173\u95ed\u56fe\u7247\u67e5\u770b\u5668" ("Close image viewer"), "\u4e0a\u4e00\u5f20" ("Previous image"), "\u4e0b\u4e00\u5f20" ("Next image"), and `\u67e5\u770b\u7b2c ${i + 1} \u5f20` ("View image N").

Related

Sparkline · LiveProductCard · DiffStat · ScoreRing · Badge · Dot

PreviousOrg classroomData DisplayNextDanmaku

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Example
    • Usage notes
    • Related