Lightbox
Full-screen image viewer (Radix Dialog) on ink (stays dark in dark mode): the image frame centered, mono “03 / 04” counter and caption, Prev/Next text buttons and arrow-key navigation, thumbnails strip.
mono-clean/ui/lightboxSource
"use client";
import { useState, type KeyboardEvent, type ReactNode } from "react";
import { Dialog } from "radix-ui";
import { cn } from "@/lib/utils";
export interface LightboxProps {
trigger?: ReactNode;
defaultOpen?: boolean;
images?: { caption: string; ratio: "landscape" | "portrait" }[];
da?: string;
}
const DEFAULT_IMAGES: NonNullable<LightboxProps["images"]> = [
{ caption: "Oslo Opera — Main signage", ratio: "landscape" },
{ caption: "Oslo Opera — Season poster", ratio: "portrait" },
{ caption: "Oslo Opera — Ticket system", ratio: "landscape" },
{ caption: "Oslo Opera — Program booklet", ratio: "portrait" },
];
/** Full-screen image viewer (Radix Dialog) on ink (stays dark in dark mode): the image frame centered, mono “03 / 04” counter and caption, Prev/Next text buttons and arrow-key navigation, thumbnails strip. */
export function Lightbox({ trigger, defaultOpen, images = DEFAULT_IMAGES, da = "mono-clean" }: LightboxProps) {
const [i, setI] = useState(0);
const img = images[i] ?? images[0]!;
const go = (d: number) => setI((x) => (x + d + images.length) % images.length);
const pad = (n: number) => String(n).padStart(2, "0");
const key = (e: KeyboardEvent) => {
if (e.key === "ArrowRight") go(1);
if (e.key === "ArrowLeft") go(-1);
};
return (
<Dialog.Root defaultOpen={defaultOpen}>
{trigger && <Dialog.Trigger asChild>{trigger}</Dialog.Trigger>}
<Dialog.Portal>
<Dialog.Content
data-da={da}
onKeyDown={key}
className="fixed inset-0 z-50 flex flex-col bg-(--lb) text-(--lbfg) outline-none [--lb:var(--da-fg)] [--lbfg:var(--da-bg)] dark:[--lb:var(--da-bg)] dark:[--lbfg:var(--da-fg)] transition-opacity duration-(--da-duration) starting:opacity-0"
>
<div className="flex items-center justify-between px-5 py-4 font-da-mono text-[11px] tracking-da-label uppercase">
<Dialog.Title aria-live="polite">
{pad(i + 1)} / {pad(images.length)} — {img.caption}
</Dialog.Title>
<Dialog.Description className="sr-only">Use the left and right arrow keys to browse images.</Dialog.Description>
<Dialog.Close className="da-focus rounded-da-sm hover:underline">Close</Dialog.Close>
</div>
<div className="grid min-h-0 flex-1 grid-cols-[auto_1fr_auto] items-center gap-4 px-5">
<button
type="button"
onClick={() => go(-1)}
className="da-focus rounded-da-sm font-da-mono text-[11px] tracking-da-label uppercase hover:underline"
>
Prev
</button>
<div
key={i}
role="img"
aria-label={img.caption}
className={cn(
"mx-auto max-h-full bg-(--lbfg)/15 transition-opacity duration-(--da-duration) starting:opacity-0",
img.ratio === "landscape" ? "aspect-[4/3] w-full max-w-3xl" : "aspect-[3/4] h-full max-h-[70dvh]",
)}
/>
<button type="button" onClick={() => go(1)} className="da-focus rounded-da-sm font-da-mono text-[11px] tracking-da-label uppercase hover:underline">
Next
</button>
</div>
<div className="flex justify-center gap-2 px-5 py-5">
{images.map((im, j) => (
<button
key={im.caption}
type="button"
aria-label={`Show ${im.caption}`}
aria-current={j === i ? "true" : undefined}
onClick={() => setI(j)}
className={cn(
"da-focus h-10 w-14 bg-(--lbfg)/15 transition-opacity",
j === i ? "outline-2 outline-offset-2 outline-(--lbfg)" : "opacity-50 hover:opacity-100",
)}
/>
))}
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
);
}
export default Lightbox;
modules/mono-clean/ui/lightbox/index.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| trigger | ReactNode | — | Trigger. |
| defaultOpen | boolean | — | Default Open. |
| images | { caption: string; ratio: "landscape" | "portrait" }[] | — | Images. |
| da | string | — | DA scope applied to portalled content. |
Other modal variants in Mono Clean
Command Dialog
Command palette (Radix Dialog + listbox): a square panel near the top with a large borderless search, grouped results under mono headings, arrow-key navigation with an inverted active row and shortcut hints.
Drawer
Right side panel (Radix Dialog) sliding in over a dimmed page: mono top bar with label and “Close”, large title, scrollable body with ruled rows and a sticky footer.
Modal
Square dialog (Radix): a mono label + text “Close” in the top bar, a full-ink rule, a large title, body and right-aligned actions; opens with a quick fade and 8px rise.
Modal in other art directions
Confirm Dialog
Destructive confirmation (Radix AlertDialog) over a hazard-striped overlay: red 'Danger zone' band, consequences list, and a type-the-name field that arms the delete button; async pending state.
Drawer
Side sheet (Radix Dialog) sliding in from the right or left in stepped motion: yellow title band with close square, scrollable body for forms, ruled footer actions.
Modal
Accessible dialog on Radix Dialog: colored title band (primary or danger), close button, scrollable body, footer action bar. Re-applies the DA scope inside the portal. Stepped drop-in entrance.
Onboarding Modal
Multi-step onboarding dialog: a colored visual panel (giant step number by default) next to title, description, segmented progress bar and Back/Next buttons; resets on open.
Bottom Sheet
Mobile-style bottom sheet (Radix Dialog): heavily frosted panel sliding up with a grab handle, title and description; becomes a floating centered card on wider screens.
Dropdown Menu
Frosted dropdown menu (Radix DropdownMenu) built from an items array: labels, icons, shortcuts, separators, checkbox items, nested submenus and a danger item.
Modal
Frosted glass sheet dialog (Radix): 40px backdrop blur, optional icon bubble, rise-and-pop entrance with overshoot, blurred overlay, round close button and footer actions.
Share Dialog
Glass share dialog: invite-by-email field with role select, people-with-access list, a general access switch (invited only / anyone with link) and a copy-link button with confirmation.
Command Palette
⌘K command palette (Radix Dialog): search input, results filtered as you type and grouped (actions, incidents, schedules), icons and shortcuts, arrow-key highlight, Enter to run, footer hints.
Modal
Radix-based dialog with fade + subtle scale entrance, optional icon, title/description, scrollable body and a tinted footer action bar. Re-applies the DA scope inside the portal.
Popover Card
Anchored popover (Radix Popover) with arrow, optional title + close button and any content — quick forms (snooze), definitions or details. Collision-aware placement.
Sheet
Side sheet (Radix Dialog) sliding in from the right or left over a dimmed overlay: title and description header with close button, scrollable body and footer actions.
Confirm Dialog
Destructive confirmation (Radix AlertDialog): red warning icon, title, consequence text, optional “type VOID to confirm” guard, cancel + red confirm.
Modal
Corporate dialog (Radix): white card with header (title, description, close), divided scrollable body and a tinted footer bar for actions; quick fade + slight scale.
Payment Modal
Pay-invoice dialog: amount summary, card/bank method radio cards, method-specific fields, secure note and a pay button that switches to a success state.
Side Sheet
Detail drawer (Radix Dialog) sliding in from the right: full-height bordered panel with sticky header, scrollable body and footer actions — for record details.
Bottom Sheet
Bottom sheet (Radix Dialog): slides up from the bottom with a grab handle and very rounded top corners; becomes a centered card from sm up.
Confirm Dialog
Gentle confirmation (Radix AlertDialog): a wilting-leaf illustration in a clay circle, serif question, kind consequence text, a sage “keep” action and a quiet clay confirm.
Modal
Soft dialog (Radix): large-radius cream card that rises gently with a slight overshoot, serif title, round close button and pill actions.
Welcome Modal
Onboarding dialog: an illustrated tinted header (sprout growing with each step), serif title and copy, leaf-shaped step dots, Back/Next pills and “Let’s begin” on the last step.
Celebrate Modal
“Week complete!” celebration dialog: pastel confetti shapes burst from the center, trophy emoji, friendly copy, three pastel stat tiles and one pill button.
Confirm Sheet
Destructive confirmation shown as a bottom sheet on mobile and a centered card on desktop: big emoji in a red-tint circle, gentle copy, red confirm with pending state and a soft cancel.
Modal
Soft modal (Radix Dialog): big rounded white card popping in with a small bounce, pastel emoji circle, round close button, body and pill footer actions.
Popover Menu
Rounded dropdown menu (Radix DropdownMenu) with emoji items, keyboard hints, soft highlight, separators and a red danger item; pops in with a bounce.