Skip to content
English
Deck accordion comes with Pro. Its preview shows once you unlock it.

How it works

Every deck is the same height (set from the longest list) and positioned with transform only: the open deck at the top, the closed ones stacked below it, each tucked 12px under the one above so the rounded bottom of each deck overlaps the next. A closed deck is cut down to its header with clip-path: inset(), and the shadow of the deck above is painted as a short gradient on it, because clip-path removes outer shadows. Choosing a deck lifts it onto the top layer for the trip; it rises on an ease-out and unfolds 120ms later while the old deck folds on an ease-in-out and slides into its place in the pile. Rows rise in one by one, 40ms apart. A ticked row's label is crossed out by an SVG stroke drawn to its measured width: a slightly wavy line past both ends with a short flick back, seeded by the row's id so it stays the same. Until the width is measured (and in server-rendered HTML) a plain line-through stands in. A ring in each header fills with the share of rows done and draws a check when all are.

Use it for

  • A few related checklists on one screen: shopping, packing, chores, onboarding steps.
  • Mobile task views where only one list needs room at a time and the others stay one tap away.
  • Grouped settings or steps where finishing each item should feel satisfying.

Look elsewhere when

  • Long lists (more than about eight rows) or many decks: the pile grows and the decks stop feeling like cards. Use a plain list or tabs.
  • Content that people compare side by side; only one deck is open at a time.
  • Rows that need more than one line of text.

Usage

import { DeckAccordion } from './DeckAccordion.jsx'

export function WeekLists({ lists, done, onToggle }) {
  return (
    <DeckAccordion
      decks={lists.map((list) => ({
        id: list.id,
        title: list.name,
        tone: list.colour,
        rows: list.items.map((item) => ({ id: item.id, label: item.text, meta: item.amount })),
      }))}
      done={done}
      onRowChange={(listId, itemId, next) => onToggle(listId, itemId, next)}
    />
  )
}

Props

PropTypeDefaultWhat it does
decks{ id: string, title: ReactNode, tone?: 1–8, icon?: ReactNode, rows: { id: string, label: ReactNode, meta?: ReactNode, done?: boolean }[] }[]—The lists, in reading order. tone picks a chart colour (--ds-chart-1 to 8) for the deck's tint, ring and checkboxes. A row's done is its starting state when `done` is not passed; meta is shown on the right (an amount, a day, an avatar).
valuestring—The id of the open deck (controlled).
defaultValuestringdecks[0].idThe deck open at first when uncontrolled.
onChange(id: string) => void—Called when another deck is chosen.
donestring[]—The rows that are done (controlled), as "deckId/rowId" keys. Leave it out to let the component keep its own state, starting from each row's done.
onRowChange(deckId: string, rowId: string, done: boolean) => void—Called whenever a row is ticked or unticked.
labels{ count: (done: number, total: number) => string }—Writes the progress shown in each header; the default is “2 of 4”.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root <div>.

Accessibility

  • Each header is a button inside an h3 with aria-expanded and aria-controls, following the accordion pattern; the open deck's header is marked aria-disabled because one deck is always open.
  • Up and Down arrows move between headers in the order they are seen (the open deck first), Home and End jump to the first and last; Tab follows the order of the decks in the data.
  • Closed decks are inert, so their rows are not reachable until the deck is open.
  • Each row is a native checkbox with its label, toggled by click, tap or Space; the focus ring is shown on the box. Done is shown by the tick, the strike and a quieter text colour, not by colour alone.
  • Reduced motion swaps decks at once and shows ticks, strikes and the ring without drawing them.

Motion

Coming forward: 560ms cubic-bezier(0.16, 1, 0.3, 1), unfolding over 480ms from 120ms in. Going back: fold 360ms and slide 560ms on cubic-bezier(0.65, 0, 0.35, 1). Rows: 320ms fade and 420ms rise from 200ms, 40ms apart; out in 140ms. Strike: 460ms cubic-bezier(0.5, 0.05, 0.25, 1), like a quick pen; erasing 200ms.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

DeckAccordion.jsxdeck-accordion.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Lists & layout
Arc carousel comes with Pro. Its preview shows once you unlock it.
Cylinder carousel comes with Pro. Its preview shows once you unlock it.