# Expand all

> Controlled value with expand-all / collapse-all buttons.

A shadcn/ui block from the [@flx](https://ui.flexnative.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/flx/accordion-14).

- Page, with a live preview: https://shadcn.exchange/r/flx/accordion-14
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/flx/accordion-14-light-398ea78b5151e720.png
- Registry item: https://ui.flexnative.com/r/accordion-14.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.flexnative.com/r/accordion-14.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `accordion`, `button`

## Files

### `registry/patterns/accordion/accordion-14.tsx`

```tsx
'use client'

import { useState } from 'react'

import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from '@/components/ui/accordion'
import { Button } from '@/components/ui/button'

const items = [
  {
    value: 'item-1',
    title: 'Step 1 — Create your account',
    body: 'Sign up with your email and verify it to unlock your workspace.',
  },
  {
    value: 'item-2',
    title: 'Step 2 — Invite your team',
    body: 'Add teammates by email and assign them roles.',
  },
  {
    value: 'item-3',
    title: 'Step 3 — Connect your tools',
    body: 'Link the integrations your team already uses.',
  },
]

const allValues = items.map((item) => item.value)

export function Accordion14() {
  const [open, setOpen] = useState<string[]>([allValues[0]])

  return (
    <div className="flex w-full max-w-md flex-col gap-3">
      <div className="flex justify-end gap-2">
        <Button
          variant="outline"
          size="sm"
          onClick={() => setOpen(allValues)}
          disabled={open.length === allValues.length}
        >
          Expand all
        </Button>
        <Button
          variant="outline"
          size="sm"
          onClick={() => setOpen([])}
          disabled={open.length === 0}
        >
          Collapse all
        </Button>
      </div>
      <Accordion multiple value={open} onValueChange={setOpen}>
        {items.map((item) => (
          <AccordionItem key={item.value} value={item.value}>
            <AccordionTrigger>{item.title}</AccordionTrigger>
            <AccordionContent className="text-muted-foreground">
              {item.body}
            </AccordionContent>
          </AccordionItem>
        ))}
      </Accordion>
    </div>
  )
}
```
