Accordion List
Divided rows that open by height; closed rows dim until hovered.
$npx shadcn@latest add https://framebrick.co/r/accordion-list.jsonFrom the Nitip template, see it in context.
Positioning, audience research and a clear voice, so every page speaks to the right people.
Layouts, type and motion designed together, tested at every screen size before a line of code.
Fast, accessible sites built on Next.js, with content your team can edit without a developer.
import { AccordionList } from "@/components/ui/accordion-list";
const items = [
{
value: "strategy",
marker: "01",
title: "Brand strategy",
content: "Positioning, audience research and a clear voice, so every page speaks to the right people.",
},
{
value: "design",
marker: "02",
title: "Web design",
content: "Layouts, type and motion designed together, tested at every screen size before a line of code.",
},
{
value: "development",
marker: "03",
title: "Development",
content: "Fast, accessible sites built on Next.js, with content your team can edit without a developer.",
},
];
export default function AccordionListDemo() {
return (
<div className="w-full max-w-md">
<AccordionList items={items} defaultValue={["strategy"]} />
</div>
);
}Examples
Cards
Separate cards that open with a click anywhere on them; the open one stays open and turns dark.
Positioning, audience research and a clear voice, so every page speaks to the right people.
Layouts, type and motion designed together, tested at every screen size before a line of code.
Fast, accessible sites built on Next.js, with content your team can edit without a developer.
import { AccordionList } from "@/components/ui/accordion-list";
const items = [
{
value: "strategy",
title: "Brand strategy",
content: "Positioning, audience research and a clear voice, so every page speaks to the right people.",
},
{
value: "design",
title: "Web design",
content: "Layouts, type and motion designed together, tested at every screen size before a line of code.",
},
{
value: "development",
title: "Development",
content: "Fast, accessible sites built on Next.js, with content your team can edit without a developer.",
},
];
/* Cards that stay open (collapsible={false}); the open one turns dark through data-state, so no colour is shipped. */
export default function AccordionListCardsDemo() {
return (
<div className="w-full max-w-md">
<AccordionList
variant="cards"
icon="plus-minus"
collapsible={false}
defaultValue={["design"]}
items={items}
className="[&>[data-state=open]]:bg-foreground [&>[data-state=open]]:text-background"
/>
</div>
);
}<AccordionList
variant="cards"
icon="plus-minus"
collapsible={false}
defaultValue={["design"]}
className="[&>[data-state=open]]:bg-foreground [&>[data-state=open]]:text-background"
items={items}
/>Installation
$ npx shadcn@latest add https://framebrick.co/r/accordion-list.json1. Install the dependencies.
npm install motion clsx tailwind-merge2. Add
cn()tolib/utils.ts(skip if shadcn already created it).import { clsx, type ClassValue } from "clsx"; import { extendTailwindMerge } from "tailwind-merge"; /* tailwind-merge must know the site's type scale (globals.css) is a font size, not a text color — otherwise cn("text-h6 text-muted-foreground") drops text-h6. */ const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-size": [{ text: ["display", "h1", "h2", "h3", "h4", "h5", "h6"] }] } }, }); export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }3. Copy the component into
components/ui/accordion-list.tsx."use client"; import * as React from "react"; import { motion, type Transition } from "motion/react"; import { cn } from "@/lib/utils"; /* * Accordion List — shadcn-style divided rows that open by height (from the Nitip service and careers lists). * Closed rows sit at 70% opacity and return to full on hover; the plus turns into a cross when open. * (Framer dims them to 50%, which drops the marker and the title below 3:1 in every theme — owner, 2026-10-01.) * Closed panels stay in the HTML (good for search engines) but are inert, so keyboards and screen readers skip them. * * Three options come from Ciketo's FAQ and services lists: * icon="plus-minus" the upright bar lies down (rotate 90° → 0) and fades, on a spring with a little bounce (0.2); * variant="cards" cards 10px apart with padding, and a click anywhere on the card toggles it. Every row carries * data-state="open" | "closed", so an open card is styled with `data-[state=open]:…` — no colour * is shipped. A click inside the open panel does not toggle it, so text can be selected and * links followed (Ciketo's toggles on any click); * collapsible={false} in "single" mode the open row stays open — a click on it does nothing. */ const soft: Transition = { type: "spring", bounce: 0, duration: 0.4 }; const bouncy: Transition = { type: "spring", bounce: 0.2, duration: 0.4 }; export type AccordionListItem = { value: string; title: React.ReactNode; content: React.ReactNode; /** Shown before the title from 640px up: a number, a dot, an icon. */ marker?: React.ReactNode; }; export type AccordionListProps = { items: AccordionListItem[]; /** "single" closes the open row when another opens. */ type?: "single" | "multiple"; /** In "single" mode: may the open row be closed by clicking it again? */ collapsible?: boolean; defaultValue?: string[]; value?: string[]; onValueChange?: (value: string[]) => void; /** Dim closed rows to 70%. On for the list, off for the cards unless you set it. */ dim?: boolean; /** "list": rows divided by lines. "cards": separate cards, clickable anywhere. */ variant?: "list" | "cards"; /** "plus": turns into a cross. "plus-minus": the upright bar lies down and fades. */ icon?: "plus" | "plus-minus"; className?: string; }; export function AccordionList({ items, type = "single", collapsible = true, defaultValue = [], value, onValueChange, dim, variant = "list", icon = "plus", className, }: AccordionListProps) { const [internal, setInternal] = React.useState<string[]>(defaultValue); const open = value ?? internal; const id = React.useId(); const cards = variant === "cards"; const dimmed = dim ?? !cards; function toggle(item: string) { const isOpen = open.includes(item); if (isOpen && type === "single" && !collapsible) return; const next = isOpen ? open.filter((v) => v !== item) : type === "single" ? [item] : [...open, item]; if (value === undefined) setInternal(next); onValueChange?.(next); } return ( <div className={cn(cards ? "flex w-full flex-col gap-2.5" : "w-full", className)}> {items.map((item, index) => { const isOpen = open.includes(item.value); /* Ids come from the index, never from the value: a value with a space would make aria-controls a list of two ids and point at nothing (axe, 2026-10-01). */ const panelId = `${id}-${index}-panel`; const triggerId = `${id}-${index}-trigger`; /* A dimmed row multiplies everything inside it by 70%: muted-foreground would land at 2.7:1. The cards inherit the card's colour instead of naming one, so a caller can turn the open card dark and its marker, icon and text follow; they are softened with opacity, not with a colour that would not survive the inversion. */ const tone = cards ? dimmed && !isOpen ? "opacity-95" : "opacity-70" : dimmed && !isOpen ? "text-foreground/95" : "text-muted-foreground"; return ( <div key={item.value} data-state={isOpen ? "open" : "closed"} /* In the cards the click lands on the card, so the button must not toggle as well. A keyboard press on the button is a click that bubbles here, so the keyboard still works. */ onClick={ cards ? (event) => { if (!(event.target as HTMLElement).closest("[data-accordion-panel]")) toggle(item.value); } : undefined } className={cn( cards ? "cursor-pointer rounded-lg border bg-card p-5 text-card-foreground" : "border-b last:border-b-0", "transition-opacity duration-400 ease-out", dimmed && !isOpen && "opacity-70 hover:opacity-100 has-focus-visible:opacity-100", )} > <h3> <button id={triggerId} type="button" aria-expanded={isOpen} aria-controls={panelId} onClick={cards ? undefined : () => toggle(item.value)} className={cn( "flex w-full cursor-pointer items-center gap-4 rounded-md text-left text-sm font-medium outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", cards ? "py-0" : "py-4", )} > {item.marker && <span className={cn("hidden w-8 shrink-0 tabular-nums sm:flex", tone)}>{item.marker}</span>} <span className="flex-1">{item.title}</span> {icon === "plus-minus" ? ( <span aria-hidden className={cn("relative size-4 shrink-0", tone)}> <span className="absolute top-1/2 left-0 h-0.5 w-full -translate-y-1/2 rounded-full bg-current" /> <motion.span initial={false} animate={{ rotate: isOpen ? 90 : 0, opacity: isOpen ? 0 : 1 }} transition={bouncy} className="absolute top-0 left-1/2 h-full w-0.5 -translate-x-1/2 rounded-full bg-current" /> </span> ) : ( <motion.svg aria-hidden viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" className={cn("size-4 shrink-0", tone)} initial={false} animate={{ rotate: isOpen ? 45 : 0 }} transition={soft} > <path d="M12 4v16M4 12h16" /> </motion.svg> )} </button> </h3> <motion.div id={panelId} data-accordion-panel="" role="region" aria-labelledby={triggerId} inert={!isOpen} initial={false} animate={isOpen ? "open" : "closed"} variants={{ open: { height: "auto", opacity: 1, transition: { height: soft, opacity: { duration: 0.25, delay: 0.1 } } }, closed: { height: 0, opacity: 0, transition: { height: soft, opacity: { duration: 0.15 } } }, }} className={cn("overflow-hidden", cards && "cursor-auto")} > <div className={cn("text-sm", cards ? "pt-3 opacity-80" : "pb-4 text-muted-foreground", item.marker && "sm:pl-12")}> {item.content} </div> </motion.div> </div> ); })} </div> ); }
Usage
import { AccordionList } from "@/components/ui/accordion-list";
<AccordionList
defaultValue={["design"]}
items={[
{ value: "design", marker: "01", title: "Web design", content: "…" },
{ value: "build", marker: "02", title: "Development", content: "…" },
]}
/>
// Ciketo's cards: a minus when open, and the open one stays open
<AccordionList
variant="cards"
icon="plus-minus"
collapsible={false}
defaultValue={["design"]}
className="[&>[data-state=open]]:bg-foreground [&>[data-state=open]]:text-background"
items={items}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { value, title, content, marker? }[] | — | Rows. The marker (number, dot, icon) shows from 640 px up. |
| type | "single" | "multiple" | "single" | Single closes the open row when another opens. |
| collapsible | boolean | true | In "single" mode: may the open row be closed by clicking it again? With false it stays open — set `defaultValue` so one starts open. |
| value | string[] | — | Open rows (controlled). |
| defaultValue | string[] | [] | Initially open rows (uncontrolled). |
| onValueChange | (value: string[]) => void | — | Called when rows open or close. |
| dim | boolean | true for the list, false for the cards | Closed rows sit at 70% opacity until hovered (Framer dims to 50%, which fails contrast). |
| variant | "list" | "cards" | "list" | Rows divided by lines, or separate cards 10 px apart that open with a click anywhere on them (Ciketo's). |
| icon | "plus" | "plus-minus" | "plus" | The plus turns into a cross, or the upright bar lies down and fades so it becomes a minus (Ciketo's). |
- Closed panels stay in the HTML (search engines read them) but are inert, so keyboards and screen readers skip them.
- Ids come from the row's position, so a value with a space in it cannot break aria-controls.
- In a dimmed row the marker and the icon carry a darker tone: the row's 70% multiplies their colour, and muted-foreground would land at 2.7:1.
- Every row carries data-state="open" or "closed", so an open card is styled with `data-[state=open]:bg-foreground data-[state=open]:text-background` — the library ships no accent of its own.
- In the cards a click inside the open panel does not toggle it, so text can be selected and links followed. Ciketo toggles on any click; this is the difference.
AI prompt
Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.
Create a React + Tailwind CSS + Motion (motion/react) component called AccordionList.
- Proportions of the shadcn/ui Accordion: rows with border-b (none on the last), trigger py-4 text-sm font-medium.
- Each row: a full-width button with an optional marker (muted, tabular numbers, hidden under 640px), the title and a
16px muted plus icon.
Open: the plus rotates 45° into a cross (spring, no bounce, 0.4s).
- The panel animates height 0 → auto with the same spring; its opacity fades in 0.25s after a 0.1s delay and fades out in 0.15s.
- Closed rows are 70% opacity and return to 100% on hover or keyboard focus (0.4s ease-out). The text inside a dimmed
row (marker, icon) uses text-foreground/95: the row's 70% multiplies its colour, and muted-foreground would fall to 2.7:1.
- Props: items {value,title,content,marker?}[], type single|multiple, collapsible (single mode: may the open row be
closed again, default true), value/defaultValue/onValueChange (string[]), dim, variant list|cards, icon plus|plus-minus.
- icon "plus-minus": two bars; the horizontal one stays, the vertical one rotates 90° and fades to opacity 0 with a
spring (bounce 0.2, 0.4s), so the plus becomes a minus.
- variant "cards": a flex column with gap-2.5; each row is rounded-lg border bg-card p-5 and a click anywhere on the card
toggles it — put the handler on the card, not the button, or it would toggle twice; ignore clicks inside the panel so
text can be selected. Dim is off unless asked for.
- In the cards, do not name colours for the marker, icon and text: inherit the card's colour and soften with opacity
(marker and icon 70%, text 80%), so a caller who turns the open card dark gets a readable marker, icon and text.
- Put data-state="open"|"closed" on every row so callers can style the open one.
- Accessibility: aria-expanded / aria-controls on the button, role region + aria-labelledby on the panel,
closed panels stay rendered but inert.










