Spiral Diary

A top-bound spiral diary whose pages hang from the wire. Drag a page up to curl it over the spiral, or drag it down to rip it off the perforation — turned and torn pages recycle to the back of the stack, so the diary never runs out.

Monday

Slow start

Coffee, then the long walk by the river.
Page 1 of 4

Installation

  1. 1

    Install the component:

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

    Usage:

    jsx

    app/page.jsx

    import SpiralDiary, { DiaryEntry } from "@/components/ui/spiral-diary";<SpiralDiary  pages={[    <DiaryEntry key="mon" date="Monday" title="Slow start">      Coffee, then the long walk by the river.    </DiaryEntry>,    <DiaryEntry key="tue" date="Tuesday" title="Deadline">      Shipped it. Slept badly anyway.    </DiaryEntry>,    <DiaryEntry key="wed" date="Wednesday" title="Rain">      Stayed in. Finished the book.    </DiaryEntry>,  ]}  width={380}  headroom={0.6}  grabZone={0.4}  theme={{ page: "#fffdf6", spiral: "#e9c46a" }}  onPageChange={(index) => {}}/>

Props

PropTypeDefaultDescriptionRequired
pagesReactNode[] | any[][]Page contents — React nodes, or any data when renderPage is used. Pages recycle to the back of the stack after a turn or tear.No
renderPage(page, index, { isTop, slot }) => ReactNodeundefinedCustom renderer for each page. meta.isTop marks the grabbable page, slot is the position in the stack (0 = top).No
initialPagenumber0Index of the page shown first.No
widthnumber380Max page width in px. The diary is fluid below this.No
aspectRationumber0.78Page width / height.No
stackDepthnumber3Visible layers of the stack (1-6).No
stackOffsetnumber4px each lower page peeks out at the bottom.No
tiltnumber0.5Max random tilt in degrees of the lower pages.No
headroomnumber0Fraction of the page height reserved above the spiral for the flipped-over page. 0 = the flipped page overlaps whatever sits above — do not put overflow-hidden on a parent.No
theme{ page, pageBack, ink, lines, marginLine, hole, spiral, spiralShade }DEFAULT_THEMEMerged over the exported DEFAULT_THEME. Set hole to the colour behind the diary so the punched holes look real.No
radiusnumber6Page corner radius in px.No
ruledbooleantrueShow ruled lines.No
ruleSpacingnumber28px between ruled lines. Match your text line-height to this and text sits on the lines.No
marginbooleantrueShow the vertical margin line.No
marginXnumber52px of the margin line from the left edge.No
texturebooleantrueSubtle paper grain — generated once as a static noise tile.No
stubHeightnumber34px of the punched band at the top of each page.No
ringSpacingnumber22px between spiral rings / holes.No
ringThicknessnumber4.5Spiral wire thickness in px.No
contentPaddingstringderived from stubHeight and marginXCSS padding string for page content.No
contentClassNamestring""Extra classes for the content wrapper — fonts, text size, etc.No
classNamestring""Extra classes on the root element.No
styleReact.CSSPropertiesundefinedInline styles on the root element.No
ariaLabelstring"Spiral diary"Accessible label.No
grabZonenumber0.4Fraction (0-1) of the page height, from the bottom, that can be grabbed. 1 = grab anywhere (page content stops being clickable); ~0.15 if pages contain inputs.No
enableTurnbooleantrueAllow dragging up to turn pages over the spiral.No
enableTearbooleantrueAllow dragging down to tear pages off the perforation.No
foldThresholdnumber0.330-1 — how far the curl must travel before release turns the page.No
tearThresholdnumber0.3Drag distance (fraction of page height) that tears the page free.No
flicknumber700px/s release speed that commits a turn or tear.No
curlRadiusnumber26px roundness of the curl highlight.No
maxFoldAnglenumber30Degrees — how diagonal the curl may get.No
tearAnglenumber10Degrees the page swings while tearing.No
peekbooleantrueHover corner-curl hint (mouse only).No
peekSizenumber26px size of the hover hint curl.No
hintbooleantruePlay the hint curl once after mount.No
keyboardbooleantrueArrow/PageUp/PageDown turn pages, Delete tears. The diary root must be focused.No
onTurn(pageIndex: number) => voidundefinedFires when a page is turned over the spiral.No
onTear(pageIndex: number) => voidundefinedFires when a page is torn off.No
onPageChange(pageIndex: number) => voidundefinedFires when the page on top changes — index into pages.No
refReact.Ref<{ next, prev, tear }>undefinedImperative handle: next() turns the top page over the spiral, prev() brings the last page back, tear() rips the top page off.No