Book Carousel

An open book with soft, flexible 3D page flips. Pages can be images, videos or any React component, and one image can span both sides of a spread.

Spread 1 of 6

Installation

  1. 1

    Install the component:

    npx shadcn@latest add https://ui.amines.fun/registry/book-carousel.json
  2. 2

    Usage:

    jsx

    app/page.jsx

    const pages = [  "/bgs/pt1.jpg",  "/bgs/pt2.jpg",  { src: "/bg2.jpg", spread: true },  "/bgs/pt4.jpg",  "/bgs/pt5.jpg",];<BookCarousel pages={pages} pageRatio={0.75} maxWidth={860} flipDuration={1100} bendStrength={1.1} />

Props

PropTypeDefaultDescriptionRequired
pages(string | ReactElement | ((page: { active: boolean, side: "left" | "right", index: number }) => ReactNode) | { src: string, alt?: string, fit?: "cover" | "contain", position?: string } | { video: string, poster?: string, loop?: boolean, muted?: boolean, autoPlay?: boolean, controls?: boolean, fit?: "cover" | "contain", position?: string } | { content: ReactNode | ((page: { active: boolean, side: "left" | "right", index: number }) => ReactNode) } | ({ ...item, spread: true }) | null)[][]Flat page list, laid out two per spread; an odd count gets a trailing blank. Each item may be an image URL string, any React element, a render function ({ active, side, index }) => node, an image object { src, alt?, fit?, position? }, a video object { video, poster?, loop?, muted?, autoPlay?, controls?, fit?, position? } that plays only while its page is visible, a { content } object for custom content, or null for a blank page. Add spread: true to any object item to lay it across both pages of a spread (auto-aligned to a left page). Every object item also accepts className and style for that page's paper.No
pageRationumber0.75Width / height of ONE page. The book's height comes from its width and this ratio.No
maxWidthnumber | string960Max width of the book — a px number or any CSS length. The book fills its parent's width up to this.No
coverThicknessnumber0.030–0.1. Cover border as a fraction of the book width. The page stacks are drawn inside this border, so keep it at 0.02 or more to see them. 0 removes the cover and the stacks.No
blankFirstbooleanfalseStart with an empty left page, so the first content page sits alone on the right like a real book.No
bendnumber6Strips per curling sheet. More = smoother curve with a little more work. Below 2 = no curling.No
bendStrengthnumber1How much the paper flexes and wobbles. 0 = stiff, 1 = normal, ~1.5 = floppy. Forced to 0 under prefers-reduced-motion.No
showStackbooleantrueShow the sheets piled under both halves of the book; they peel away one by one as you turn.No
stackSheetsnumber8Max visible stacked sheets per side.No
flipDurationnumber1000ms. Duration of one page flip. 0 (or prefers-reduced-motion) snaps pages instantly.No
easing[number, number, number, number] | string[0.65, 0, 0.35, 1]Framer Motion ease — a cubic-bezier array or a named ease like "easeInOut".No
indexnumber-Controlled spread index (0 = first spread). Pair with onChange.No
defaultIndexnumber0Initial spread when uncontrolled.No
onChange(index: number, prevIndex: number) => void-Fires when a flip starts.No
onFlipEnd(index: number) => void-Fires when all pages have landed.No
autoPlaybooleanfalseFlip automatically. Pauses when the book is off-screen or the tab is hidden.No
autoPlayDelaynumber4000ms between flips, counted after the previous flip lands.No
loopbooleantrueAt the last spread, autoplay flips back to the first one. If false, autoplay stops there.No
pauseOnHoverbooleantruePause autoplay while the mouse is over the book.No
showControlsbooleantruePrev / next buttons under the book.No
showCounterbooleantrue"1 / 5" counter between the buttons.No
keyboardbooleantrueArrow ←/→ and Home/End flip pages while the book is focused.No
swipebooleantrueSwipe / drag sideways to flip.No
edgeClickbooleantrueClick the outer edge of a page to flip. Turn off if your pages contain buttons or links near their edges.No
preloadnumber2How many spreads on each side of the current one keep their pages mounted.No
classNamestring""Classes for the outer wrapper.No
coverClassNamestring"bg-[#86613a] dark:bg-[#4a3826]"Cover colors (replaces the default).No
pageClassNamestring"bg-[#fbfaf5] dark:bg-neutral-800"Paper colors (replaces the default).No
stackClassNamestring"bg-[#ece8db] dark:bg-neutral-700"Stacked-sheet colors (replaces the default).No
controlsClassNamestring""Classes for the controls row.No
ariaLabelstring"Book"Accessible name for the book region.No
refRef<{ next(): void, prev(): void, goTo(i: number): void, play(): void, pause(): void, toggle(): void, getIndex(): number, spreadCount: number }>-Imperative API: next() / prev() flip one spread, goTo(i) jumps to spread i (multi-spread jumps flip in a quick stagger), play() / pause() / toggle() drive autoplay, getIndex() returns the current spread index, spreadCount is the total number of spreads.No