CMS Media Bento
A CMS-ready media bento whose weighted slicing tree re-solves the whole composition around the tile you hover. Ten color portraits from the Spiral Media Gallery set, adaptive captions, and a keyboard-friendly lightbox.
Installation#
pnpm dlx shadcn@latest add @davinciui/cms-media-bentoUsage#
Give the component a sized parent. The default ten-item layout switches between wide and tall slicing trees from the measured aspect ratio, collapses to a two-column grid below 520px, and re-solves every split when a tile is hovered. All media is lazy-loaded imagery and the lightbox is keyboard accessible.
API Reference#
| Prop | Type | Default |
|---|---|---|
itemsImage entries. The first ten drive the canonical bento; other counts receive a balanced weighted tree. Each item needs src, plus optional title, category, description, link, size, and alt. | BentoItem[] | — |
gapSpace between tiles and around the stage, in pixels. | number | 10 |
radiusCorner radius applied to every tile and lightbox media. | number | 14 |
backgroundOverrides the themed stage surface. Defaults to a warm off-white in light mode and near-black in dark mode. | string | var(--bento-surface) |
captionsCaption visibility. Mobile grids show captions whenever they are not hidden. | "always" | "hover" | "hidden" | "hover" |
hoverGrowWeight multiplier for the hovered tile. The entire layout re-solves, not just the tile. | number | 1.8 |
focusDimOpacity of the focus veil over non-hovered tiles while one tile is active. Uses the current surface token. | number | 0.35 |
hoverZoomMedia scale while its tile is hovered. | number | 1.04 |
mirrorMirror the layout horizontally without mirroring media. | boolean | false |
openLightboxOpen the focused media in a dialog. When false, item links navigate. | boolean | true |
transitionMsLayout re-solve duration in milliseconds. | number | 420 |
minHeightMinimum root height in pixels. | number | 520 |
mobileBreakpointWidth below which the layout collapses to the scrolling two-column grid. Set to 0 to keep the bento composition at any size. | number | 520 |
classNameAdditional classes for the root element. | string | — |
Accessibility#
Each tile is a native button, so Enter and Space open the lightbox without custom key handling; the bento itself adds no roving tabindex and every tile is reachable in source order. Lightbox dialogs use aria-modal, focus the close control on open, cycle Tab inside, close on Escape, and restore focus to the tile. Images keep meaningful alt text and honor lazy loading outside the first five tiles.
Motion#
A weighted slicing tree re-solves every split when the hovered tile's weight is multiplied by hoverGrow, and the resulting left, top, width, and height values transition over transitionMs with cubic-bezier(0.22,1,0.36,1). Media scales to hoverZoom, the focus veil fades over 300ms, and tiles enter with a 14px rise and 0.985 scale staggered 60ms apart. prefers-reduced-motion removes layout, entrance, zoom, and lightbox motion while keeping captions and the lightbox itself.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

