vaiperui

components / accordion

Accordion

Stack of sections that expand and collapse, with keyboard navigation.

How to use

`type="single"` keeps one section open (add `collapsible` to allow closing it); `type="multiple"` lets several stay open. Use `defaultValue` or `value` + `onValueChange` (a string for single, `string[]` for multiple). Arrow Up/Down, Home and End move focus between headers.

preview

We accept credit card, bank slip and Pix.

Accordion.tsx
import { Accordion, AccordionItem } from "vaiperui";
<Accordion type="single" collapsible defaultValue="payment">
<AccordionItem value="payment" title="Which payment methods?">
We accept credit card, bank slip and Pix.
</AccordionItem>
</Accordion>

Multiple

preview

…

…
multiple
multiple.tsx
<Accordion type="multiple" defaultValue={["payment", "shipping"]}>…</Accordion>

Colors

preview

primary

success

warning

danger
colors.tsx
<Accordion type="single" variantColor="primary">…</Accordion>
<Accordion type="single" variantColor="success">…</Accordion>
<Accordion type="single" variantColor="warning">…</Accordion>
<Accordion type="single" variantColor="danger">…</Accordion>

Props

PropValuesDefaultDescription
typesingle | multiplerequiredOne or several sections open
collapsiblebooleanfalseSingle only: allow closing the open section
value / defaultValuestring | string[]noneOpen item value(s), controlled / initial
onValueChange(value) => voidnoneCalled with the new value(s); "" when single closes
variantColorprimary | success | warning | dangerprimaryFocus ring color
customColorstring | { light, dark }noneAny CSS color (or a pair per theme) for the focus ring
animationnone | smooth | fast | bouncesmoothChevron transition
value (item)stringrequiredAccordionItem identifier
title (item)ReactNoderequiredAccordionItem header
disabled (item)booleanfalseCannot be expanded or focused
(native)divnoneEvery native prop of the element, className, ref, etc.