# Accordion

> Cherry Accordion component - animated disclosure with a card style and an inline variant.

Source: https://cherry.al/code/accordion

> For the complete documentation index, see [llms.txt](https://cherry.al/llms.txt).

# Accordion

<iframe className="light-only" src="https://demo.cherry.al/preview/accordion?theme=light" title="Accordion" loading="lazy" style={{ width: "100%", height: "340px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />
<iframe className="dark-only" src="https://demo.cherry.al/preview/accordion?theme=dark" title="Accordion" loading="lazy" style={{ width: "100%", height: "340px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />

<iframe className="light-only" src="https://demo.cherry.al/preview/accordion-inline?theme=light" title="Inline accordion" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />
<iframe className="dark-only" src="https://demo.cherry.al/preview/accordion-inline?theme=dark" title="Inline accordion" loading="lazy" style={{ width: "100%", height: "320px", border: "1px solid var(--color-grayLight)", borderRadius: "12px" }} />

The Accordion component shows and hides content behind a clickable title. It animates open and close, rotates its chevron to match, and respects `prefers-reduced-motion`.

For design guidelines and all interactive states, see the [Accordions](/accordions) design page.

```jsx
import React from "react";
import { Accordion } from "cherry-styled-components";

export default function Page() {
  return (
    <Accordion title="What is Cherry?">
      Cherry is a design system for the modern web.
    </Accordion>
  );
}
```

The inline variant drops the border, radius, and side padding for embedding inside cards or lists:

```html
<Accordion title="Inline accordion" $inline>
  Content
</Accordion>
```

By default the accordion manages its own state. Pass `open` and `onToggle` to control it from the parent:

```html
<Accordion title="Controlled" open={isOpen} onToggle={setIsOpen}>
  Content
</Accordion>
```

## Properties

<Field value="children" type="React.ReactNode" required>
  The collapsible content.
</Field>

<Field value="title" type="React.ReactNode" required>
  The always-visible clickable title.
</Field>

<Field value="$inline" type="boolean">
  Removes the border, radius, and side padding for a flush, compact look.
</Field>

<Field value="defaultOpen" type="boolean">
  Renders the accordion open initially (uncontrolled mode).
</Field>

<Field value="open" type="boolean">
  Controlled open state. When provided, the parent owns open/close; pair it
  with `onToggle`.
</Field>

<Field value="onToggle" type="(isOpen: boolean) => void">
  Called with the next state whenever the title is clicked.
</Field>

All other standard `div` attributes (`className`, `id`, `style`, `aria-*`, and
so on) are passed through to the root element; the native `title` and
`onToggle` attributes are replaced by the props above.

<Button href="https://github.com/cherry-design-system/styled-components/blob/main/src/lib/accordion.tsx" icon="code" iconPosition="left">
  View Source
</Button>
