Accordion
An accordion is a vertically stacked set of interactive headings that hide or reveal associated content panels.
Import
import { Accordion } from "@cfa/react-core";Live Editor
Examples
Default
The basic accordion allows one panel to be open at a time.
Individual
You can also render an individual Accordion.Item outside of a group.
Multiple Expanded
Use allowsMultipleExpanded to enable multiple panels to be opened simultaneously.
Default Expanded
Use defaultExpandedKeys to specify which items should be expanded when the accordion first renders.
Elevated Items
Use the isElevated prop to give each accordion item a raised appearance.
Within Surface
The Accordion can be placed within a Surface component for additional styling.
Disabled
The entire accordion can be disabled using the isDisabled prop.
Visit the Documentation Site for the full list of props.
| Name | Type | Default | Description |
|---|---|---|---|
| isElevated | boolean | false | Elevates the accordion, giving it a raised appearance. |
| panelPadding | number | - | - |
| allowsMultipleExpanded | boolean | - | Whether multiple items can be expanded at the same time. |
| children | ChildrenOrFunction<DisclosureGroupRenderProps> | - | The children of the component. A function may be provided to alter the children based on component state. |
| className | ClassNameOrFunction<DisclosureGroupRenderProps> | 'react-aria-DisclosureGroup' | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. |
| defaultExpandedKeys | Iterable<Key> | - | The initial expanded keys in the group (uncontrolled). |
| dir | string | - | - |
| expandedKeys | Iterable<Key> | - | The currently expanded keys in the group (controlled). |
| hidden | boolean | - | - |
| id | string | - | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
| inert | boolean | - | - |
| isDisabled | boolean | - | Whether all items are disabled. |
| lang | string | - | - |
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | - | - |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | - | - |
| onAuxClick | MouseEventHandler<HTMLDivElement> | - | - |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onClick | MouseEventHandler<HTMLDivElement> | - | - |
| onClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenu | MouseEventHandler<HTMLDivElement> | - | - |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | - | - |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onExpandedChange | (keys: Set<Key>) => any | - | Handler that is called when items are expanded or collapsed. |
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onMouseDown | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMove | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOut | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOver | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUp | MouseEventHandler<HTMLDivElement> | - | - |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | - | - |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDown | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMove | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOut | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOver | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUp | PointerEventHandler<HTMLDivElement> | - | - |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | - | - |
| onScroll | UIEventHandler<HTMLDivElement> | - | - |
| onScrollCapture | UIEventHandler<HTMLDivElement> | - | - |
| onTouchCancel | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMove | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStart | TouchEventHandler<HTMLDivElement> | - | - |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | - | - |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | - | - |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | - | - |
| onWheel | WheelEventHandler<HTMLDivElement> | - | - |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | - | - |
| render | DOMRenderFunction<"div", DisclosureGroupRenderProps> | - | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: * You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). * Only a single root DOM element can be rendered (no fragments). * You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| style | StyleOrFunction<DisclosureGroupRenderProps> | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. |
| translate | "yes" | "no" | - | - |