Skip to main content
AccordionItem
@coinbase/cds-web@9.0.2
An individual collapsible item within an Accordion.
import { AccordionItem } from '@coinbase/cds-web/accordion/AccordionItem'
Peer dependencies
  • framer-motion: ^10.18.0
Related components

AccordionItem represents a single expandable section within an Accordion. It composes an AccordionHeader (clickable trigger) and AccordionPanel (collapsible content) into a single component.

Basics​

Each AccordionItem requires a unique itemKey to identify it within the parent Accordion, and a title for the header text. The children become the collapsible content.

Loading...

Header Content​

Title and Subtitle​

Use the title prop for the main header text and subtitle for secondary information.

Loading...

Media​

Add icons, avatars, or other media to the header using the media prop. This commonly uses CellMedia for consistent styling.

Loading...

Click Handling​

Use the onClick callback to respond when an item is clicked. It receives the itemKey as an argument.

Loading...

Panel Content​

Rich Content​

AccordionItem children can contain any React content—forms, lists, buttons, or other components.

Loading...

Max Height​

Use maxHeight to limit the panel height for items with potentially long content. The content will scroll if it exceeds this height.

Loading...

Multiple Items​

When using multiple AccordionItems, only one can be expanded at a time (controlled by the parent Accordion). Use defaultActiveKey on the Accordion to specify which item starts expanded.

Loading...

Accessibility​

AccordionItem automatically provides accessible behavior:

  • The header uses proper ARIA attributes (aria-expanded, aria-controls)
  • Content is wrapped in a region role with aria-labelledby pointing to the header
  • Full keyboard navigation is supported via the parent Accordion

For items with complex content, ensure any interactive elements inside the panel are keyboard accessible.

Loading...

Refs​

Use headerRef and panelRef to get references to the header button and panel elements for programmatic focus management or measurements.

function RefExample() {
const headerRef = useRef(null);
const panelRef = useRef(null);

const focusHeader = useCallback(() => {
headerRef.current?.focus();
}, []);

return (
<Accordion>
<AccordionItem itemKey="1" title="Focusable Item" headerRef={headerRef} panelRef={panelRef}>
<Text as="p" font="body" color="fgMuted">
Panel content
</Text>
</AccordionItem>
</Accordion>
);
}

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.