Give it the items, a trigger per photo, and the content.
trip-photos.tsx
Lightbox
| Prop | Type | Default | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| items | — | The photos and videos of the set, in order (LightboxItem from #/lib/lightbox-state). | |||||||||||||||||||||||||||||||
| index | number | — | The current item (controlled). | ||||||||||||||||||||||||||||||
| default | number | 0 | The first item shown when the viewer opens with no trigger. Default 0. | ||||||||||||||||||||||||||||||
| on | — | ||||||||||||||||||||||||||||||||
| loop | boolean | false | After the last item, the next one is the first. Default false. It needs 3 items or more: with 2, the one neighbour would have to sit on both sides of the track at once, so a swipe would show an empty side and a change would come in from the wrong side. | ||||||||||||||||||||||||||||||
| max | number | 4 | The largest zoom (4 = 400%). Default 4. | ||||||||||||||||||||||||||||||
| slideshow | number | SLIDESHOW_INTERVAL_MS | The time of one photo in the slideshow, in ms. Default 5000. | ||||||||||||||||||||||||||||||
| handle | — | Opens this Lightbox from triggers outside it (createLightboxHandle). | |||||||||||||||||||||||||||||||
| labels | — | The words of the parts (LIGHTBOX_LABELS), in the page language. Keep the object stable. | |||||||||||||||||||||||||||||||
| children | ReactNode | — | |||||||||||||||||||||||||||||||
From Base UIDialog.RootBase UI docs | |||||||||||||||||||||||||||||||||
| open | boolean | — | Whether the dialog is currently open. | ||||||||||||||||||||||||||||||
| default | boolean | false | Whether the dialog is initially open. To render a controlled dialog, use the open prop instead. | ||||||||||||||||||||||||||||||
| modal | "trap-focus" | boolean | true | Determines if the dialog enters a modal state when open. - true: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled. - false: user interaction with the rest of the document is allowed. - 'trap-focus': focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled. When modal is true or 'trap-focus', render <Dialog.Close> inside <Dialog.Popup> so touch screen readers can escape the popup. | ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
LightboxTrigger
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| index | number | — | The item this trigger opens. | ||||
| handle | — | A handle, for a trigger outside its Lightbox (createLightboxHandle). | |||||
From Base UIDialog.TriggerBase UI docs | |||||||
| id | string | — | ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the dialog in controlled mode (with the DialogRoot triggerId prop). | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxThumbnail
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | — | A ready srcset for src ("a-640.jpg 640w, a-1280.jpg 1280w"), with sizes: for files that a server already made at each width. It wins over loader and transformer. Change it together with src: the old picture keeps only its src while the new one loads. |
| width | number | — | The width of the box in px. With height, it sets the box ratio before the file loads. |
| height | number | — | |
| sizes | string | — | The sizes of the srcset: how wide the box is per screen ("(max-width: 640px) 100vw, 33vw"). |
| loader | ImageLoader | — | Makes the URL of each srcset width, Next.js style. Default: the loader of the nearest ImageLoaderProvider (none outside one). |
| transformer | ImageTransformer | — | An Unpic provider transformer, an alternative to loader. |
| quality | number | — | The quality that loader and transformer get (1–100). |
| preload | boolean | — | A picture above the fold (a hero): loads at once with a high fetch priority, and React preloads it (<link rel="preload"> with the srcset). Default false: lazy. |
| placeholder | — | What shows while the file loads: muted (default, the muted box), skeleton (the box with a shimmer band), blur (blurDataURL, blurred), color (placeholderColor), none (no fill, also on an error: the parent shows), or an element: your own layer under the file until its fade ends (a sharp thumbnail of the same picture). | |
| blur | string | — | A tiny copy of the picture (10px or less, a data URL) for placeholder="blur". |
| placeholder | string | — | The main color of the picture for placeholder="color" (a data color). |
| position | string | — | The CSS object-position of the picture in the box ("top", "30% 60%"). |
| fade | boolean | — | Fade the file in when it loads. Default true. A file the page already loaded, or a server file, shows at once. |
| on | — | Called with the new status: idle, loading, loaded, error. | |
| on | — | ||
| on | — | ||
| class | string | — | The classes of the box (size, corners, ratio). |
| img | string | — | The classes of the <img>. |
| style | CSSProperties | — | |
| children | ReactNode | — | An ImageFallback for the error and the no-src box. Default: an icon (none for alt=""). With a child, the root is not role="img": the fallback speaks for itself, and an img role would hide its words and controls (a retry button) from screen readers. |
| fit | "contain""cover" | — | |
| rounded | "default""full" | — | |
| src | string | Blob | — | The file. Default: the item thumbnail, else its src. |
| alt | string | — | Default: the item alt. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxContent
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| portal | — | Other Base UI props of the inner parts. A className here adds to the component classes. | |
| backdrop | — | ||
| viewport | — | ||
From Base UIDialog.PopupBase UI docs | |||
| initial | — | Determines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - false: Do not move focus. - true: Move focus based on the default behavior (first tabbable element or popup). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing. | |
| final | — | Determines the element to focus when the dialog is closed. - false: Do not move focus. - true: Move focus based on the default behavior (trigger or previously focused element). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing. | |
| container | — | A parent element to render the portal element into. | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxStage
<section>| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "Photos" | The name of the slides region. Default "Photos". |
| ...props | <section> attributes | — | Every other attribute goes to the <section>, with a ref. |
LightboxHeader
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxFooter
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxCounter
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxToolbar
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxZoomIn
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
| label | string | "Zoom in" | The accessible name. Translate it with the page. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxZoomOut
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
| label | string | "Zoom out" | The accessible name. Translate it with the page. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxSlideshow
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxFullscreen
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxDownload
<a>| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | "Download" | |
| ...props | <a> attributes | — | Every other attribute goes to the <a>, with a ref. |
LightboxClose
<div>LightboxPrevious
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| label | string | "Previous photo" | The accessible name. Translate it with the page. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxNext
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| label | string | "Next photo" | The accessible name. Translate it with the page. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
LightboxCaption
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxTitle
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxDescription
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxThumbnails
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| thumbnail | lightboxThumbnailLabel | The name of one thumbnail button. Default "Show photo 5: Lake at dusk". | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxMain
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| room | boolean | false | Leave room for an open LightboxPanel at the inline end (on a screen of 768px and wider; a phone shows the panel as a sheet over the photo, so the room stays 0). |
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
LightboxPanel
<aside>| Left ArroworRight Arrow | Goes to the photo before or after. |
|---|---|
| HomeorEnd | Goes to the first or the last photo. |
| +or-or0 | Zooms in, zooms out, or resets the zoom. |
| Esc | Closes the viewer. |
Built with
Installs with Lightbox



