clickworks
Works / Content

Slide Viewer

Your images sit in a backlit viewer like 35mm slides, with the next ones waiting in the magazine. Pull the lever, swipe or use the arrow keys and the next slide drops in. An optional slideshow moves on by itself.

Free1 file0 dependencies5.7 kB gzippedRenders on the serverKeyboard and screen reader

Install

npx shadcn@latest add https://clickworks.dev/r/slide-viewer.json

The files land in components/clickworks/slide-viewer/. No other packages are added.

Usage

import { SlideViewer } from "@/components/clickworks/slide-viewer/react/SlideViewer"

export function Gallery() {
  return (
    <SlideViewer
      slides={[
        { image: { src: "/work/one.jpg", alt: "Kitchen after the refit" }, caption: "Kitchen" },
        { image: { src: "/work/two.jpg", alt: "Garden room at dusk" }, caption: "Garden room" },
      ]}
    />
  )
}

Props

slides
{ image: { src, alt }, caption? }[]

The slides, in order.

label
string

Accessible name of the gallery.

Default "Gallery"

mark
string

Engraved on the viewer.

theme
"auto" | "light" | "dark"

Auto follows the page (its background, data-theme or dark class), then the device.

Default "auto"

light / dark
{ body?, light?, mount?, caption?, text?, shadow? }

Colours for each theme.

auto
boolean

Moves on by itself.

Default false

interval
number

Seconds per slide in the slideshow.

Default 5

sound / haptics
boolean

The lever click and a short buzz on phones.

Default true

Events

onChange
() => void

The slide changed.

Styling

Colours come in through the light and dark props. It fills its width and keeps its proportions.

Behaviour and accessibility

  • Arrow keys, swipe and the lever all change the slide.
  • The slideshow pauses while hovered or focused.
  • Each slide keeps its alt text.
  • With reduced motion slides change without the drop.

Files

react/SlideViewer.tsxReact component