Skip to contentKino
Skip to Content

Accordion

Sections that open one at a time or several at once, as flat rows or as a card whose open item breaks away.

npx shadcn add https://kinoui.com/r/accordion.json
Share on

Examples

Default

One section is open at a time. A panel pushes what sits below it, and turns back from where it is when you close it midway.

Card

The items share one card. The open item breaks away from the others, and its plus becomes a minus.

Several open at once

With multiple, opening a section leaves the others as they are.

Icons and counts

An icon sits before the title. When something follows the title, wrap the title so it takes the room between them.

Disabled

A disabled item fades and stays closed.

Content that changes height

Content that grows or shrinks while its panel is open takes the panel, and the rows below, with it.

Installation

npx shadcn@latest add https://kinoui.com/r/accordion.json
Files
lib/reduce-motion.tslib/resize.tslib/scroll.tscomponents/kino/accordion.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Accordion

PropTypeDefaultDescription
variant'default''card''default'Flat rows, or one card whose open item breaks away.
multiplebooleanfalseLets several items be open at once.
defaultValueany[]NoneThe values of the items open at first, when you leave the state to the accordion. An array, also when only one can be open.
valueany[]NoneThe values of the open items, when you hold the state.
onValueChange(value) => voidNoneCalled when an item opens or closes.
disabledbooleanfalseDisables every item.
hiddenUntilFoundbooleanfalseLets the browser's find in page search closed panels and open the one it lands on. Chromium and Firefox support it.

AccordionItem

PropTypeDefaultDescription
valueanyNoneWhat names the item in value and defaultValue.
disabledbooleanfalseFades the item and keeps it as it is.

AccordionContent

PropTypeDefaultDescription
classNamestringNoneGoes on the box with the padding, the one you lay out.
keepMountedbooleanfalseKeeps the content in the page while the item is closed.

Data attributes

AttributeOnDescription
data-openAccordionItem, AccordionContentPresent while the item is open.
data-panel-openAccordionTriggerPresent while its item is open.
data-disabledAccordionItem, AccordionTrigger, AccordionContentPresent while the item is disabled.
data-variantAccordiondefault or card.

CSS variables

VariableSet it onDefaultDescription
--accordion-gapAccordion, or anything above it0.5remThe gap around the open item in the card variant.

Accessibility

  • Tab moves from one header to the next, and Enter or Space opens or closes the focused one.
  • Each header is an h3.
  • With one item open at a time, opening an item closes the one above it, which could carry the header you pressed out of view. The accordion holds that header at the top edge while the page scrolls under it. Under a sticky header, set scroll-padding-top on the scroller, or scroll-margin-top on the triggers, to the header's height.
  • When the system asks for less motion, a panel opens and closes at once, the indicator and the card jump to their place, and content still fades.