Figure
shadcn-htmx/figureFreeComponent
Self-contained, referenced content — an image, diagram, code block, or quotation — wrapped in a native <figure> whose <figcaption> supplies its accessible name. Distinct from a Card's generic surface: a figure stands apart from the main flow and can be moved without breaking it, and its caption is semantically tied to the content. Built on native <figure> + <figcaption>, zero JavaScript.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/figure.jsonSource
1/** @jsxImportSource hono/jsx */2import type { Child, PropsWithChildren } from "hono/jsx"3import { cn, type ClassValue } from "@/registry/lib/cn"45// Figure — shadcn-htmx, htmx v4 + Tailwind v4.6//7// Self-contained captioned content — an image, diagram, code block, or8// quotation — wrapped in a native <figure> whose <figcaption> supplies the9// figure's accessible name. Unlike <Card> (a generic styled surface),10// <Figure> is *referential*: it stands apart from the main flow and can be11// moved elsewhere without breaking it, and the caption is semantically tied12// to the content. No interactivity, no JavaScript.13//14// Built on (native elements; we add nothing the platform doesn't ship):15// - <figure> — represents self-contained content, optionally captioned;16// the figure, its caption, and its contents are one unit. Implicit ARIA17// role "figure".18// repos/mdn/files/en-us/web/html/reference/elements/figure/index.md19// - <figcaption> — caption/legend for the parent <figure>; provides the20// <figure> its accessible name. Must be the figure's first or last child21// (the first <figcaption> found is presented as the caption).22// repos/mdn/files/en-us/web/html/reference/elements/figcaption/index.md23//24// Anatomy mirrors shadcn's Card family (read for intent only, not copied —25// different element, different semantics):26// repos/shadcn-ui/apps/v4/registry/new-york-v4/ui/card.tsx27//28// Theme tokens only: border / bg-card / text-card-foreground for the surface,29// text-muted-foreground for the caption, bg-muted for plain content slots.3031// Where the caption sits relative to the content. Both are valid per the32// spec (first OR last child); we render the <figcaption> in the chosen DOM33// position so the accessible name is correct either way.34export type FigureCaptionSide = "top" | "bottom"3536type FigureProps = PropsWithChildren<{37 class?: ClassValue38 id?: string39 // Caption position. "bottom" (default) reads as a credit/label under the40 // content; "top" reads as a legend introducing it (common for code blocks41 // and quotations). See the MDN figure examples.42 captionSide?: FigureCaptionSide43 // Forward hx-*, data-*, aria-* and standard global attributes onto the44 // <figure> root.45 [key: string]: unknown46}>4748// Surface: a bordered card-like box. We keep it visually distinct from the49// document body but lighter than a full Card (no shadow) so it reads as50// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
