# Grouped Collapsible

> Several collapsible panels stacked together so readers open one section at a time. Good for settings pages where related options sit in separate groups.

A shadcn/ui block from the [@shadcn-ui-blocks](https://www.shadcn-ui-blocks.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/shadcn-ui-blocks/components-collapsible-grouped-collapsible).

- Page, with a live preview: https://shadcn.exchange/r/shadcn-ui-blocks/components-collapsible-grouped-collapsible
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/shadcn-ui-blocks/components-collapsible-grouped-collapsible-light-8fc841f50147c7d7.png
- Registry item: https://www.shadcn-ui-blocks.com/r/components-collapsible-grouped-collapsible.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://www.shadcn-ui-blocks.com/r/components-collapsible-grouped-collapsible.json
```

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

## Dependencies

- npm packages: `lucide-react`, `radix-ui`

## Files

### `components/blocks/components/collapsible/grouped-collapsible.tsx`

```tsx
import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from '@/components/ui/collapsible';
import { ChevronDown, ChevronUp } from 'lucide-react';
import { useState } from 'react';

export default function GroupedCollapsible() {
  const [openSections, setOpenSections] = useState<Record<string, boolean>>({
    shipping: false,
    payment: false,
    returns: false,
  });

  const toggleSection = (section: string) => {
    setOpenSections((prev) => ({
      ...prev,
      [section]: !prev[section],
    }));
  };

  return (
    <div className="mx-auto max-w-md py-6">
      <div className="divide-y overflow-hidden rounded-md border">
        {/* Shipping Section */}
        <Collapsible
          className="w-full"
          open={openSections.shipping}
          onOpenChange={() => toggleSection('shipping')}
        >
          <CollapsibleTrigger className="hover:bg-muted/10 flex w-full items-center justify-between px-4 py-3 transition-colors">
            <span className="font-medium">Shipping Information</span>
            {openSections.shipping ? (
              <ChevronUp className="h-4 w-4 shrink-0 transition-transform duration-200" />
            ) : (
              <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
            )}
          </CollapsibleTrigger>
          <CollapsibleContent>
            <div className="text-muted-foreground border-t px-4 py-3 text-sm">
              <p>
                We offer free shipping on all orders over $50. Standard shipping
                takes 3-5 business days.
              </p>
            </div>
          </CollapsibleContent>
        </Collapsible>

        {/* Payment Section */}
        <Collapsible
          className="w-full"
          open={openSections.payment}
          onOpenChange={() => toggleSection('payment')}
        >
          <CollapsibleTrigger className="hover:bg-muted/10 flex w-full items-center justify-between px-4 py-3 transition-colors">
            <span className="font-medium">Payment Options</span>
            {openSections.payment ? (
              <ChevronUp className="h-4 w-4 shrink-0 transition-transform duration-200" />
            ) : (
              <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
            )}
          </CollapsibleTrigger>
          <CollapsibleContent>
            <div className="text-muted-foreground border-t px-4 py-3 text-sm">
              <p>
                We accept all major credit cards, PayPal, and Apple Pay. All
                transactions are secure and encrypted.
              </p>
            </div>
          </CollapsibleContent>
        </Collapsible>

        {/* Returns Section */}
        <Collapsible
          className="w-full"
          open={openSections.returns}
          onOpenChange={() => toggleSection('returns')}
        >
          <CollapsibleTrigger className="hover:bg-muted/10 flex w-full items-center justify-between px-4 py-3 transition-colors">
            <span className="font-medium">Return Policy</span>
            {openSections.returns ? (
              <ChevronUp className="h-4 w-4 shrink-0 transition-transform duration-200" />
            ) : (
              <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
            )}
          </CollapsibleTrigger>
          <CollapsibleContent>
            <div className="text-muted-foreground border-t px-4 py-3 text-sm">
              <p>
                Returns are accepted within 30 days of purchase. Items must be
                in original condition with tags attached.
              </p>
            </div>
          </CollapsibleContent>
        </Collapsible>
      </div>
    </div>
  );
}
```

### `components/ui/collapsible.tsx`

```tsx
"use client"

import { Collapsible as CollapsiblePrimitive } from "radix-ui"

function Collapsible({
  ...props
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
  return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
}

function CollapsibleTrigger({
  ...props
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
  return (
    <CollapsiblePrimitive.CollapsibleTrigger
      data-slot="collapsible-trigger"
      {...props}
    />
  )
}

function CollapsibleContent({
  ...props
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
  return (
    <CollapsiblePrimitive.CollapsibleContent
      data-slot="collapsible-content"
      {...props}
    />
  )
}

export { Collapsible, CollapsibleTrigger, CollapsibleContent }
```
