Accordion

A vertically stacked set of interactive headings that each reveal a section of content.

Overview

The Accordion component provides an interactive way to display collapsible content sections. Built on Base UI primitives, it supports single or multiple item expansion with customizable variants and smooth CSS transitions.

Usage

import {
  Accordion,
  AccordionHeader,
  AccordionItem,
  AccordionPanel,
  AccordionTrigger,
} from "@tilt-legal/cubitt-components/primitives";
<Accordion multiple={false}>
  <AccordionItem value="item-1">
    <AccordionHeader>
      <AccordionTrigger>Is it accessible?</AccordionTrigger>
    </AccordionHeader>
    <AccordionPanel>
      Yes. It adheres to the WAI-ARIA design pattern.
    </AccordionPanel>
  </AccordionItem>
</Accordion>

Examples

Solid

Outline

Custom Indicators

Multiple Open Items

Nested Accordions

Auto-Play

URL State

API Reference

Accordion

PropTypeDescription
valuestring[]The controlled value of the accordion (array of open item values).
defaultValuestring[]The default value when uncontrolled.
onValueChange(value: string[], eventDetails) => voidCallback fired when the value changes.
multiplebooleanWhether multiple items can be open at once. Defaults to true.
disabledbooleanWhether the accordion is disabled. Defaults to false.
hiddenUntilFoundbooleanAllows browser's page search to find and expand panel contents. Defaults to false.
loopbooleanWhether to loop keyboard focus back to the first item. Defaults to true.
orientation"horizontal" | "vertical"The visual orientation of the accordion. Defaults to "vertical".
keepMountedbooleanWhether to keep panels in the DOM while closed. Defaults to false.
variant"default" | "outline" | "solid"Visual style variant. Defaults to "default".
indicator"arrow" | "plus" | "none"Icon indicator type. Defaults to "arrow".
itemsstring[]Ordered list of item values for auto-play cycling. Required when autoPlay is true.
autoPlaybooleanWhether to automatically advance to the next item. Defaults to false.
autoPlayIntervalnumberDuration in milliseconds before auto-advancing. Defaults to 5000.
loopbooleanWhether to loop back to the first item after the last. Defaults to true.
classNamestringAdditional CSS classes for the accordion.
renderReactElement | functionAllows replacing the component's HTML element.

URL State Props

When provided with a paramName, the accordion's state will be reflected in the URL.

PropTypeDescription
paramNamestringURL parameter name for syncing state with URL. When provided, enables URL state management.
paramValuestring[]Controlled value for the URL parameter (syncs with accordion value).
onUrlValueChange(value: string[] | null) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleanRemove URL param when value equals default. Defaults to true.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

AccordionItem

PropTypeDescription
valuestringThe unique value for this accordion item. Required.
disabledbooleanWhether this item is disabled.
classNamestringAdditional CSS classes for the item.

AccordionHeader

PropTypeDescription
classNamestringAdditional CSS classes for the header.

AccordionTrigger

PropTypeDescription
classNamestringAdditional CSS classes for the trigger.

AccordionPanel

PropTypeDescription
classNamestringAdditional CSS classes for the panel.
keepMountedbooleanWhether to keep the panel in the DOM while closed. Defaults to false.

AccordionProgress

PropTypeDescription
classNamestringAdditional CSS classes for the progress bar. Only renders when autoPlay is enabled on the root.

Design Guidelines

Layout & Positioning

  • Use accordions to organize related information into collapsible sections
  • Keep trigger labels concise and descriptive
  • Consider the content hierarchy when nesting accordions
  • Ensure adequate spacing between items for touch targets

Visual Hierarchy

  • Use clear visual states for expanded/collapsed items
  • Provide visual feedback for user interactions
  • Use indicators to show expandable content
  • Maintain consistent styling across all accordion items

Accessibility

  • Provide meaningful labels for each accordion trigger
  • Use proper ARIA attributes for screen readers
  • Ensure keyboard navigation works correctly
  • Consider focus management when items expand/collapse

On this page