BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diklein/dk-media-viewer

DKMediaViewer

diklein/dk-media-viewer
FreeComponent

A minimalist, performant, and elegant photo and video viewer for React. Masonry grid, fly-in lightbox, a crossfading carousel, captions and camera EXIF data, light and dark modes, reduced-motion support, keyboard navigation, and one easter egg.

Install it

npx shadcn@latest add https://diklein.com/r/dk-media-viewer.json

Source

registry/dk-media-viewer/dk-media-viewer.tsxdiklein.com/r/dk-media-viewer.json · first 6 KB
1'use client'
2
3/* DKMediaViewer — the masonry grid + the lightbox it opens.
4 *
5 * <DKMediaViewer items={items} />
6 *
7 * Items are plain data (see types.ts) — hand-written, CMS-mapped, or generated with
8 * `npx @diklein/dkmediaviewer scan ./public/photos`. Photos render as lazy <img>s (or through your own
9 * renderImage slot, e.g. next/image); videos autoplay muted in the grid and hand off
10 * frame-accurately to the lightbox player when clicked. */
11
12import { useState, useEffect, useRef } from 'react'
13import type { DKMediaItem } from './types'
14import { useDKLightbox } from './dk-lightbox'
15
16export interface DKMediaViewerProps {
17 items: DKMediaItem[]
18 /** Extra classes on the outer grid wrapper. */
19 className?: string
20 /** A sharper large variant for the lightbox to fade in over the base image (and to prefetch
21 * on hover and around the open item) — e.g. a CDN resize URL. Default: none; the lightbox
22 * shows item.src, which for local files is already the full image. */
23 getHiResSrc?: (item: DKMediaItem) => string
24 /** Render the grid image yourself (e.g. with next/image). Apply ctx.className to the visible
25 * image element and honor ctx.sizes/ctx.priority; the lightbox still works untouched — it
26 * reads the rendered <img>'s decoded file at click time. */
27 renderImage?: (
28 item: DKMediaItem,
29 ctx: { index: number; priority: boolean; sizes: string; className: string },
30 ) => React.ReactNode
31 /** The 1px photo edge outline in the lightbox. Default true (photographs). */
32 showOutline?: boolean
33 /** Reserve the lightbox caption/exif rail. Default: on when any item carries one. */
34 hasCaptions?: boolean
35 /** Open from `?photo=<index>` on mount, for shareable deep links. Default off. */
36 deepLink?: boolean
37}
38
39const GRID_SIZES = '(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw'
40const IMG_CLASS = 'dk-img-outline w-full h-auto transition-opacity duration-200 group-hover:opacity-85'
41
42export function DKMediaViewer({
43 items,
44 className,
45 getHiResSrc,
46 renderImage,
47 showOutline = true,
48 hasCaptions,
49 deepLink = false,
50}: DKMediaViewerProps) {
51 const [numCols, setNumCols] = useState(3)
52 const prefetched = useRef<Set<string>>(new Set())
53 // Thumbnail registry: close hands focus back to the item the viewer ended on, and deep links
54 // need a zoom origin — both resolved through here.
55 const thumbEls = useRef<Map<number, HTMLButtonElement>>(new Map())
56
57 const { open, lightbox } = useDKLightbox(items, {
58// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • registry/dk-media-viewer/dk-media-viewer.tsx
  • registry/dk-media-viewer/dk-lightbox.tsx
  • registry/dk-media-viewer/dk-carousel.tsx
  • registry/dk-media-viewer/types.ts
  • registry/dk-media-viewer/dk-media-viewer.css

Facts

Registry
diklein
Type
registry:component
Access
Free
Files written
5
Licence
MIT
In the index
at or before 2026-08-11
Last confirmed
today

Go to the source

diklein.com diklein/dkmediaviewer on GitHub Raw registry item This item as JSON

More from diklein

All 3 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
DKBezelerdk-bezelerdikleinComponentsFreeno deps · 2 files
DKProductCarddk-product-carddikleinComponentsFree1 dep · 2 files

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex