Bookshelf
A cinematic 3D bookshelf showcase where physical-looking books rotate into view, bringing different front covers to the foreground while surrounding spines remain visible.
Installation#
pnpm dlx shadcn@latest add @davinciui/bookshelfUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
booksBooks in shelf order. Each item accepts id, title, optional subtitle, author, cover image URL, color, coverColor, textColor, accent, width, and thickness. | BookItem[] | [] |
initialIndexThe initially featured (cover-facing) book index. | number | 0 |
autoplayAuto-advance through books on a timer. | boolean | true |
autoplayIntervalSeconds between automatic book advances. | number | 3.5 |
transitionDurationCover rotation and shelf travel duration in seconds. | number | 1 |
perspectiveCSS perspective of the shelf stage in px. | number | 1400 |
bookHeightHeight of each book in px. | number | 340 |
gapHorizontal gap between books in px. | number | 18 |
titleHeading shown above the shelf. | string | "Favorite Books" |
showHeaderRender the serif heading and rule above the shelf. | boolean | true |
showControlsRender the previous/next buttons and index readout. | boolean | true |
decorativeRender books as non-interactive divs for card previews instead of buttons. | boolean | false |
labelAccessible name for the bookshelf group. | string | "Favorite books bookshelf" |
onActiveBookChangeFired when the featured book changes. | (index: number) => void | — |
classNameExtra classes for the outer wrapper. | string | — |
Accessibility#
Each book is a native button in the tab order with an aria-label built from its title and aria-pressed reflecting the active state. Arrow keys move focus between books, Enter and Space select, and focus-visible rings remain visible. Prev/Next controls are labelled buttons. Decorative cover, spine, and side faces are aria-hidden so titles are announced once per book.
Motion#
Books rotate around their vertical axis between spine-facing and cover-facing orientations while the shelf translates horizontally to center the active book. Neighboring books scale and recede in depth based on distance from the active position. GSAP timelines with power2.inOut easing coordinate translation and rotation. Reduced motion snaps transitions and disables autoplay.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

