Skip to content

components/Lightbox

import { … } from 'zidane-ui'ui/src/components/Lightbox.tsx

ConfirmDialog in an Overlay
Overlay + zg-float dialog
Lightbox

Functions#

useLightboxFunction#

Owns the state of an attachment lightbox. Returns open(items, index, origin?), which shows the gallery at index (clamped to the list; an empty list is ignored) and grows the image out of the origin thumbnail, close(), and element, which the caller renders once. It is null while the lightbox is closed.

TypeScript
function useLightbox(): { close: () => void; element: Element | null; open: (items: readonly LightboxItem[], index: number, origin?: HTMLElement | null) => void }
{ close: () => void; element: Element | null; open: (items: readonly LightboxItem[], index: number, origin?: HTMLElement | null) => void }

ui/src/components/Lightbox.tsx:71

Interfaces#

LightboxItemInterface#

One attachment shown in the lightbox: an image, or a text preview drawn by body.

TypeScript
interface LightboxItem
LightboxItem properties
NameTypeDescription
body?() => ReactNode

Renders the item's content when it has no src, such as a text preview.

keystring

Stable identifier for the item.

namestring

Name shown as the caption, and used as the image's alt text and the dialog's label.

src?string

Image source. Items without one render body instead (a text preview).

ui/src/components/Lightbox.tsx:38