UI

Picture view

A full-screen look at one image, with a close control and focus return.

Read Markdown

Web 0.2.0

  • Defaultlight16.95 : 1AA 4.5dark16.95 : 1AA 4.5
  • KeyboardEnterSpaceTabShift+TabEscape
  • measured on 0.2.0
npx shadcn@latest add @maeso/picture-view
Size
45.8 kB gzipmeasured on 0.2.0

Usage

Open the selected picture with meaningful descriptive text. Keep dismissal associated with the view's open state.

Accessibility

Provide useful alternative text and a keyboard close path. Preserve focus return to the element that opened the picture.

When to use

Use for inspecting an image in a dedicated overlay. Use an ordinary image when enlargement adds no useful detail.

Install

Add this registry to your project's components.json once, before the first install. Keep your existing settings and other registries.

{
  "registries": {
    "@maeso": "http://127.0.0.1:4321/r/{name}.json"
  }
}

Then install the registry's default theme once, and import its sheet in the CSS entry that imports Tailwind. It paints every item from this registry.

npx shadcn@latest add @maeso/maeso
@import "./styles/theme.web.css";
npx shadcn@latest add @maeso/picture-view

Props

PictureView

PropTypeRequiredDescription
altstringyes
childrenReactElement<unknown, string | JSXElementConstructor<any>>yesThe control that opens the view, such as a thumbnail button; it takes focus back on close.
srcstringyes
titlestringyesThe line above the picture, and the view's accessible name.
containerHTMLElement | null | undefinednoWhere the view mounts, so it shares a layer such as Point's; the document body when omitted.
layer"modal" | "point" | undefinednoThe layer over the window: `point` when the view opens from Point's layer.

Proof

Contrast

measured on 0.2.0

StateForegroundBackgroundRatioFloor
defaultrgb(7 21 34)rgb(248 245 240)16.95AA 4.5
default (dark)rgb(248 245 240)rgb(7 21 34)16.95AA 4.5

Keyboard

measured on 0.2.0

KeyAction
EnterOpen the dialog or activate its Close button
SpaceOpen the dialog from its trigger
TabMove forward and wrap focus inside the dialog
Shift+TabWrap backward focus inside the dialog
EscapeClose the dialog and restore trigger focus

Size

45784 gzip bytes · measured on 0.2.0

Motion

The picture view fades in and out.

Configured duration: 150 ms

Reduced motion: none

Motion timing

Observed duration: 150 ms · measured on 0.2.0

Reduced motion

passed · measured on 0.2.0

Example

import { PictureView } from "@/components/ui/_kit/overlay/picture-view/PictureView";

const Example = () => (
		<PictureView
			title="Atlas cover"
			alt="A flat ochre field"
			src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='180'%3E%3Crect width='320' height='180' fill='%23888'/%3E%3C/svg%3E"
		>
			<button
				type="button"
				className="px-3 py-2.5 border border-border rounded-none bg-surface-base text-ink text-(length:--text-sm)"
			>
				Open picture
			</button>
		</PictureView>
	);
export default Example;

not on native yet