# Accordion (Andromeda Pro)

Accordion is a component of the Premium Andromeda Pro design system from AI Canvas (https://aicanvas.me). Index of every system, component and install setup: https://aicanvas.me/llms.txt

Lists questions that each open their answer below them, one at a time or several at once.

- Design system: [Andromeda Pro](https://aicanvas.me/design-systems/andromeda-pro.md)
- License: Premium (proprietary)
- Install slug: `andromeda-pro-accordion`
- Page: https://aicanvas.me/design-systems/andromeda-pro/accordion

## Install

```bash
npx shadcn@latest add @aicanvas/andromeda-pro-accordion
```

Requires Premium. Without a Premium token the command writes a placeholder (a `PremiumLocked` notice) instead of the component.

Every Andromeda Pro component at once: `npx shadcn@latest add @aicanvas/andromeda-pro`.

Token setup: the Install section of https://aicanvas.me/llms.txt.

## Use it

It installs to `components/aicanvas/andromeda-pro/components/Accordion.tsx` (under `src/` if your project has one). With the usual `@/` alias:

```tsx
import { Accordion } from '@/components/aicanvas/andromeda-pro/components/Accordion'
```

## Example

```tsx
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/aicanvas/andromeda-pro/components/Accordion'

<Accordion type="single" defaultValue="billing">
  <AccordionItem value="billing">
    <AccordionTrigger>When is an invoice due?</AccordionTrigger>
    <AccordionContent>Invoices are due 30 days after issue.</AccordionContent>
  </AccordionItem>
  <AccordionItem value="payment">
    <AccordionTrigger>Which payments are accepted?</AccordionTrigger>
    <AccordionContent>Bank transfer and card payments are accepted.</AccordionContent>
  </AccordionItem>
</Accordion>
```

## Parts

Accordion is built from `Accordion`, `AccordionItem`, `AccordionTrigger` and `AccordionContent`. Each part has its own props table below.

## Variants

- `as` on `Accordion`: div, ol or ul (default 'div')

## Props

### Accordion

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type?` | `'single'\|'multiple'` | `'single'` | Single keeps one item open at a time; multiple opens items independently. |
| `collapsible?` | `boolean` | `true` | Single only: the open item closes when its trigger is pressed again, leaving none open. False keeps one open at all times. |
| `value?` | `string\|string[]` |  | Controlled open value: a string for single ('' for none), an array for multiple. Pair with onValueChange. |
| `defaultValue?` | `string\|string[]` |  | Initial open value when uncontrolled, same shape as value. |
| `onValueChange?` | `(value: string \| string[]) => void` |  | Called with the next open value: a string for single, an array for multiple. |
| `as?` | `'div'\|'ol'\|'ul'` | `'div'` | The list element. With 'ol' or 'ul' each item renders as an li, so a numbered list keeps its list semantics. |
| `children?` | `React.ReactNode` |  | AccordionItems. |
| `className?` | `string` |  | Additional CSS classes applied to the root element. |
| `style?` | `React.CSSProperties` |  | Inline styles applied to the root element. |

### AccordionItem

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` |  | Identifies the item in the group's open value. |
| `disabled?` | `boolean` | `false` | The item cannot be toggled: Collapsible's disabled state (dimmed, not-allowed cursor). It keeps whatever open state the group gives it. |
| `children?` | `React.ReactNode` |  | An AccordionTrigger followed by an AccordionContent. |
| `className?` | `string` |  | Additional CSS classes applied to the root element. |
| `style?` | `React.CSSProperties` |  | Inline styles applied to the root element. |

### AccordionTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` | `React.ReactNode` |  | The question, set at textLg in text.primary. |
| `leading?` | `React.ReactNode` |  | A short index ("01") in the glyph slot before the question: label role, tabular, text.faint at rest, text.muted while open, hovered or focused. Without it the question starts at the row inset. |
| `onClick?` | `(event: React.MouseEvent<HTMLButtonElement>) => void` |  | Runs before the toggle; call preventDefault to keep the item as it is. |
| `className?` | `string` |  | Additional CSS classes applied to the root element. |
| `style?` | `React.CSSProperties` |  | Inline styles applied to the root element. |

### AccordionContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children?` | `React.ReactNode` |  | The answer, set at textMd in text.secondary. Children stack in a column 12px apart. |
| `className?` | `string` |  | Merged onto the answer's box. |
| `style?` | `React.CSSProperties` |  | Merged onto the answer's box. |

## Remix prompt

Only when the user wants Accordion rebuilt from scratch instead of installed: the public part of its remix prompt is in the Remix panel at https://aicanvas.me/design-systems/andromeda-pro/accordion.

## More Andromeda Pro components

- [Alert](https://aicanvas.me/design-systems/andromeda-pro/alert.md)
- [Artifact](https://aicanvas.me/design-systems/andromeda-pro/artifact.md)
- [Avatar](https://aicanvas.me/design-systems/andromeda-pro/avatar.md)
- [Badge](https://aicanvas.me/design-systems/andromeda-pro/badge.md)
- [Bento Grid](https://aicanvas.me/design-systems/andromeda-pro/bento-grid.md)
