# Accordion

Give supporting details room to breathe without overwhelming the page.

## Usage

Use for supporting explanations and FAQs. Keep essential instructions visible outside the accordion. Multiple items can stay open.

Save the JSX and CSS Module in the same folder in a React project with CSS Modules support. Controlled components need parent state and change handlers.

## JSX

```jsx
"use client";
import styles from "./Disclosure.module.css";
export default function Disclosure({
  items = [
    {
      title: "What makes a useful component?",
      content:
        "Clear states, predictable behavior, and a purpose that fits the product.",
    },
  ],
}) {
  return (
    <div className={styles.accordion}>
      {items.map((item) => (
        <details className={styles.item} key={item.title}>
          <summary>
            {item.title}
            <span aria-hidden="true">+</span>
          </summary>
          <div>{item.content}</div>
        </details>
      ))}
    </div>
  );
}

```

## CSS

```css
.accordion {
  width: 100%;
  font: 15px/1.6 var(--tdp-font, "DM Sans", system-ui, sans-serif);
  color: var(--tdp-text, #302e2b);
}
.item {
  border-bottom: 1px solid var(--tdp-border, #d9d1c9);
}
.item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: var(--tdp-control-height, 48px);
  padding: 16px 4px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.item summary::-webkit-details-marker {
  display: none;
}
.item summary span {
  font-size: 24px;
  font-weight: 400;
  transition: transform 0.25s;
}
.item[open] summary span {
  transform: rotate(45deg);
}
.item > div {
  padding: 0 30px 20px 4px;
  color: var(--tdp-muted, #6b625b);
}
.accordion:focus-visible,
.accordion :where(button, input, summary):focus-visible {
  outline: 3px solid var(--tdp-focus, #7851a9);
  outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
  .accordion,
  .accordion :where(button, input, summary, span) {
    transition: none !important;
    animation: none !important;
  }
}

```

## Props

- items (array): Objects with unique title and content properties.

## Accessibility

Native details and summary expose expanded state and keyboard activation. Hidden content is removed from keyboard navigation until opened.

Check accessibility again after customizing the component.

[Browse all components](/resources/components/)

Canonical: https://designproject.io/resources/components/disclosure/

## Keep learning

- [How to create a UI color palette, step by step](https://designproject.io/resources/guides/create-ui-color-palette/)
- [Product design glossary: 44 terms explained](https://designproject.io/resources/glossary/)
- [How to choose font pairings for a product interface](https://designproject.io/resources/guides/choose-font-pairings/)
