# AccordionItem
An individual collapsible item within an Accordion.
## Import
```tsx
import { AccordionItem } from '@coinbase/cds-web/accordion/AccordionItem'
```
## Examples
AccordionItem represents a single expandable section within an [Accordion](/components/layout/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.
```jsx live
Coinbase is a secure online platform for buying, selling, transferring, and storing digital
currency.
```
### Header Content
#### Title and Subtitle
Use the `title` prop for the main header text and `subtitle` for secondary information.
```jsx live
Configure your account settings here.
```
#### Media
Add icons, avatars, or other media to the header using the `media` prop. This commonly uses `CellMedia` for consistent styling.
```jsx live
}
>
Balance
0.5 BTC
Value
$21,500.00
```
### Click Handling
Use the `onClick` callback to respond when an item is clicked. It receives the `itemKey` as an argument.
```jsx live
function ClickExample() {
const [lastClicked, setLastClicked] = useState(null);
return (
{lastClicked && (
Last clicked: {lastClicked}
)}
setLastClicked(key)}>
Content for the first item.
setLastClicked(key)}>
Content for the second item.
);
}
```
### Panel Content
#### Rich Content
AccordionItem children can contain any React content—forms, lists, buttons, or other components.
```jsx live
```
#### Max Height
Use `maxHeight` to limit the panel height for items with potentially long content. The content will scroll if it exceeds this height.
```jsx live
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
architecto beatae vitae dicta sunt explicabo.
```
### 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.
```jsx live
Download the app, create an account, and verify your identity to start trading.
Yes, we use industry-leading security measures including cold storage and two-factor
authentication to protect your assets.
Fees vary based on your payment method and transaction size. See our pricing page for details.
```
### 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.
```jsx live
Adjust settings to make the app more accessible.
```
### Refs
Use `headerRef` and `panelRef` to get references to the header button and panel elements for programmatic focus management or measurements.
```jsx
function RefExample() {
const headerRef = useRef(null);
const panelRef = useRef(null);
const focusHeader = useCallback(() => {
headerRef.current?.focus();
}, []);
return (
Panel content
);
}
```
## Props
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `children` | `null \| string \| number \| false \| true \| ReactElement> \| Iterable \| ReactPortal` | Yes | `-` | Collapsible content |
| `itemKey` | `string` | Yes | `-` | Key of the accordion item. This should be unique inside the same Accordion unless you want multiple items to be controlled at the same time. |
| `title` | `string` | Yes | `-` | Title of the accordion item |
| `headerRef` | `RefObject` | No | `-` | - |
| `maxHeight` | `ResponsiveProp>` | No | `-` | - |
| `media` | `null \| string \| number \| false \| true \| ReactElement> \| Iterable \| ReactPortal` | No | `-` | - |
| `onClick` | `((key: string) => void)` | No | `-` | Callback function fired when the accordion item is clicked |
| `panelRef` | `RefObject` | No | `-` | - |
| `style` | `CSSProperties` | No | `-` | - |
| `subtitle` | `string` | No | `-` | Subtitle of the accordion item |
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |