Accordion

Questions that open in place under a rule each, the panel easing to its measured height and the chevron turning with it.

01Preview

01
Full screen

Everything in the thread up to its context window. Older turns are summarised once a thread outgrows it.

02Installation

npx shadcn@latest add https://aiellie.app/r/accordion.json

03API reference

05
From the Base UI documentation

Groups all parts of the accordion. Renders a <div> element.

Props

PropTypeDefaultDescription
defaultValueValue[]-The uncontrolled value of the item(s) that should be initially expanded. To render a controlled accordion, use the value prop instead.
valueValue[]-The controlled value of the item(s) that should be expanded. To render an uncontrolled accordion, use the defaultValue prop instead.
onValueChange((value: Value[], eventDetails: Accordion.Root.ChangeEventDetails) => void)-Event handler called when an accordion item is expanded or collapsed. Provides the new value as an argument.
hiddenUntilFoundbooleanfalseAllows the browser's built-in page search to find and expand the panel contents. Overrides the keepMounted prop and uses hidden="until-found" to hide the element without removing it from the DOM.
loopFocusboolean-Deprecated following the [APG guidance update](https://github.com/w3c/aria-practices/pull/3434) to remove roving focus. This prop no longer affects keyboard focus behavior.
multiplebooleanfalseWhether multiple items can be open at the same time.
disabledbooleanfalseWhether the component should ignore user interaction.
orientationOrientation'vertical'Deprecated following the [APG guidance update](https://github.com/w3c/aria-practices/pull/3434) to remove roving focus. This prop no longer affects keyboard focus behavior.
classNamestring | ((state: Accordion.Root.State<Value>) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component's state.
styleReact.CSSProperties | ((state: Accordion.Root.State<Value>) => React.CSSProperties | undefined)-Style applied to the element, or a function that returns a style object based on the component's state.
keepMountedbooleanfalseWhether to keep the element in the DOM while the panel is closed. This prop is ignored when hiddenUntilFound is used.
renderReactElement | ((props: HTMLProps, state: Accordion.Root.State<Value>) => ReactElement)-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Data Attributes

AttributeTypeDescription
data-orientation-Indicates the orientation of the accordion.
data-disabled-Present when the accordion is disabled.