Accordion React component for Tailwind CSS v4
v1.0.0Added in 1.0.0
A React accordion component for FAQs, settings sections and order details, with four variants, icons, descriptions and one or many open.
Click or tap anywhere on a row to open it: the answer grows out on a smooth spring while the rows below slide down, and the chevron flips (or the plus folds into a minus). In single mode opening one row closes the other. With a keyboard, Tab reaches the rows, Up and Down move between them, Home and End jump to the first and last, and Enter or Space toggles. Rows are at least 44px tall on every size and the whole row is the target, so they are easy to hit on a phone. With keepMounted, the browser's find in page opens the row that holds the match. With reduced motion nothing slides: the answer simply fades in and out.
Accordion is a free React component in the React layout components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add accordion, together with useControllableState, Motion presets, Tones and UIProvider and the npm packages @radix-ui/react-accordion, lucide-react and motion.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add accordionUsage
Import Accordion from @/components/ui/accordion.
import { Accordion, type AccordionItemData } from "@/components/ui/accordion"
const faq: AccordionItemData[] = [
{
value: "posting",
title: "How do I post a listing?",
content: "Tap Post a listing, pick a category and upload your photos. The listing goes live within minutes.",
},
{
value: "promotion",
title: "How much does promotion cost?",
content: "Promotion starts at $9.00 for 7 days, and the listing moves to the top results.",
},
{
value: "returns",
title: "Can I return an item?",
content: "Yes, you have 14 days from delivery to return an item bought with delivery through the platform.",
},
]
export function Faq() {
return <Accordion items={faq} defaultValue="promotion" variant="separated" />
}Props
items*AccordionItemData[]The rows: { value, title, description?, icon?, extra?, content, disabled? }. value must be unique (a duplicate replaces the earlier row); extra is a short value before the indicator, like a price or a count. An empty list renders nothing.
typedefault"single""single" | "multiple"single keeps one row open at a time (value is a string); multiple lets any number stay open (value is a string[]).
collapsibledefaulttruebooleansingle type only: the open row closes again when clicked. Turn it off for sections where one must always stay open.
keepMounteddefaultfalsebooleanKeeps closed answers in the DOM (collapsed, hidden until found), so form fields keep their values, search engines read every answer and the browser's find in page opens the row that holds the match.
headingLeveldefault32 | 3 | 4 | 5 | 6The heading level that wraps each row, so the accordion fits the page outline for screen readers.
variantdefault"ghost""ghost" | "outline" | "soft" | "separated"ghost is flush with hairlines between rows, outline and soft wrap the rows in one container, separated turns every row into its own raised card.
sizedefault"md""sm" | "md" | "lg"Row height 44 / 56 / 64px with title 14 / 15 / 16px and content 13 / 14 / 15px. Even sm stays a full 44px touch target.
radiusdefault"md""none" | "sm" | "md" | "lg" | "full"Corners of the outline and soft containers and of separated cards: 12 / 16 / 24px. On ghost rows it shapes the focus ring.
indicatordefault"chevron""chevron" | "plus" | "none"The open / closed mark. The chevron turns, the plus folds into a minus; none hides it.
indicatorPositiondefault"end""start" | "end"end puts the mark after the title. start puts it first, as a chevron that points at the title and turns down like a disclosure triangle; the content indents to the title.
tonedefault"neutral""neutral" | "brand" | "success" | "warning" | "danger" | "info"Tints the open row's icon tile and indicator.
colordefault""stringAny CSS color for the open row's tint, mixed for contrast in both themes. Leave empty to use the tone.
divideddefaulttruebooleanHairlines between rows. soft insets them to the row padding like a grouped list; separated cards ignore it.
disableddefaultfalsebooleanDisables every row. Disable a single row with disabled on its item.
valuestring | string[]The open row (single) or rows (multiple), to control the accordion from outside.
defaultValuestring | string[]The open row or rows on first render. Nothing is open by default ("" or []).
onValueChange(value: string | string[]) => voidCalled with the new value: a string for single ("" when the row closes), a string[] for multiple.
classNamesPartial<Record<"item" | "trigger" | "icon" | "title" | "description" | "extra" | "indicator" | "content", string>>Extra classes for the inner parts of every row. content styles the padded inner box, not the animated wrapper.
classNamestringExtra classes for the root, merged last.
Parts
AccordionRoot
componentThe parts API, for rows that need custom markup. Takes every prop above except items and shares variant, size, indicator and tone with its parts. Props: AccordionRootProps.
AccordionItem
componentOne row. Its value is what the root's value speaks. Props: { value: string; disabled?: boolean }.
AccordionTrigger
componentThe clickable row inside its heading. children is the title; extra is a short value before the indicator. Props: { icon?: ReactNode; description?: ReactNode; extra?: ReactNode; children: ReactNode }.
AccordionContent
componentThe answer. className and props go to the padded inner box; keepMounted overrides the root's for this row. Props: ComponentProps<"div"> & { keepMounted?: boolean }.
AccordionItemData
typeOne entry of items: { value, title, description?, icon?, extra?, content, disabled? }.
Examples
Variants
Flush ghost rows, one outline or soft container, or a card per row.
Settings sections
type="multiple" with icons and descriptions; the open rows' tiles take the tone.
Plus at the start
The plus folds into a minus and the answer indents to the title. Brand tone, soft container.
Disabled row
A row that is coming soon: dimmed, skipped by the arrow keys, not clickable.
Controlled
value and onValueChange drive Open all / Close all from outside.
Order history
Separated cards built from the parts, with the total as an extra value in dollars.
Sizes
44, 56 and 64px rows; even sm keeps a full touch target.
Keep mounted, custom color
keepMounted keeps closed content in the DOM, so a half-filled field survives. Tinted with color.
Files
- components/ui/accordion.tsx
FAQ
Is the React Accordion component free?
Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.
How do I install Accordion?
Run npx wingo-ui@latest add accordion. It also adds the Wingo UI items it builds on (useControllableState, Motion presets, Tones and UIProvider) and the npm packages @radix-ui/react-accordion, lucide-react and motion. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/accordion.json.
How does Accordion behave on phones?
Rows are at least 44px tall on every size and the whole row is the target, so they are easy to hit on a phone.
See also
Used in
More React layout components
Articles using this component
- shadcn Tailwind v4 Migration: Step by Step From v3
Next.js and Tailwind CSS10 min read