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
- First install
- Add the registry once
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-viewProps
PictureView
| Prop | Type | Required | Description |
|---|---|---|---|
| alt | string | yes | |
| children | ReactElement<unknown, string | JSXElementConstructor<any>> | yes | The control that opens the view, such as a thumbnail button; it takes focus back on close. |
| src | string | yes | |
| title | string | yes | The line above the picture, and the view's accessible name. |
| container | HTMLElement | null | undefined | no | Where the view mounts, so it shares a layer such as Point's; the document body when omitted. |
| layer | "modal" | "point" | undefined | no | The layer over the window: `point` when the view opens from Point's layer. |
Proof
Contrast
measured on 0.2.0
| State | Foreground | Background | Ratio | Floor |
|---|---|---|---|---|
| default | rgb(7 21 34) | rgb(248 245 240) | 16.95 | AA 4.5 |
| default (dark) | rgb(248 245 240) | rgb(7 21 34) | 16.95 | AA 4.5 |
Keyboard
measured on 0.2.0
| Key | Action |
|---|---|
| Enter | Open the dialog or activate its Close button |
| Space | Open the dialog from its trigger |
| Tab | Move forward and wrap focus inside the dialog |
| Shift+Tab | Wrap backward focus inside the dialog |
| Escape | Close 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