Accordion

Accordion organizes content into collapsible sections.

Orders leave the warehouse within two business days.

tsx
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

<Accordion type="single" collapsible defaultValue="shipping">
  <Accordion.Item value="shipping">
    <Accordion.Trigger>Shipping</Accordion.Trigger>
    <Accordion.Content>Orders leave the warehouse within two business days.</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="returns">
    <Accordion.Trigger>Returns</Accordion.Trigger>
    <Accordion.Content>Send anything back within 30 days of delivery, free of charge.</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="warranty">
    <Accordion.Trigger>Warranty</Accordion.Trigger>
    <Accordion.Content>Every device we sell is covered for two years.</Accordion.Content>
  </Accordion.Item>
</Accordion>

Installation

pnpm dlx wideset add accordion

Copies the component and any Wideset components it uses into your project.

Examples

Contained

contained turns each section into its own card with a border and a hover fill, so sections read as separate blocks. Use it when the accordion stands alone on a page or the sections are unrelated; keep the default dividers when it sits inside a card or a side panel that already frames it.

tsx
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

export default function AccordionContained() {
  return (
    <div className="gap-ws-11 grid w-full grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]">
      {[false, true].map((contained) => (
        <Accordion
          key={String(contained)}
          type="single"
          collapsible
          defaultValue="shipping"
          contained={contained}
        >
          <Accordion.Item value="shipping">
            <Accordion.Trigger>Shipping</Accordion.Trigger>
            <Accordion.Content>
              Orders leave the warehouse within two business days.
            </Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="returns">
            <Accordion.Trigger>Returns</Accordion.Trigger>
            <Accordion.Content>
              Send anything back within 30 days, free of charge.
            </Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="warranty">
            <Accordion.Trigger>Warranty</Accordion.Trigger>
            <Accordion.Content>Every device we sell is covered for two years.</Accordion.Content>
          </Accordion.Item>
        </Accordion>
      ))}
    </div>
  );
}

Icons

Accordion.Icon goes first inside the trigger, before the label. It is hidden from screen readers, so the label alone names the section. Give every section an icon or none, so the labels stay aligned.

tsx
import { RiArrowGoBackLine, RiShieldCheckLine, RiTruckLine } from '@remixicon/react';
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

const sections = [
  {
    value: 'shipping',
    icon: RiTruckLine,
    title: 'Shipping',
    body: 'Orders leave the warehouse within two business days.',
  },
  {
    value: 'returns',
    icon: RiArrowGoBackLine,
    title: 'Returns',
    body: 'Send anything back within 30 days, free of charge.',
  },
  {
    value: 'warranty',
    icon: RiShieldCheckLine,
    title: 'Warranty',
    body: 'Every device we sell is covered for two years.',
  },
];

export default function AccordionIcons() {
  return (
    <div className="w-[22rem] max-w-full">
      <Accordion type="single" collapsible defaultValue="shipping">
        {sections.map((section) => (
          <Accordion.Item key={section.value} value={section.value}>
            <Accordion.Trigger>
              <Accordion.Icon icon={section.icon} />
              {section.title}
            </Accordion.Trigger>
            <Accordion.Content>{section.body}</Accordion.Content>
          </Accordion.Item>
        ))}
      </Accordion>
    </div>
  );
}

Captions

A caption answers the question before the section is opened: a delivery time, a price, a count. Keep it to one short line; anything longer belongs in the content. Title and caption both become part of the trigger's accessible name.

tsx
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

const sections = [
  { value: 'standard', title: 'Standard delivery', caption: '2–4 business days, free' },
  { value: 'express', title: 'Express delivery', caption: 'Next business day, €9' },
  { value: 'pickup', title: 'Pick up in store', caption: 'Ready in two hours, free' },
];

export default function AccordionCaptions() {
  return (
    <div className="w-[22rem] max-w-full">
      <Accordion type="single" collapsible defaultValue="standard">
        {sections.map((section) => (
          <Accordion.Item key={section.value} value={section.value}>
            <Accordion.Trigger>
              <div className="flex flex-col">
                <Accordion.Title>{section.title}</Accordion.Title>
                <Accordion.Caption>{section.caption}</Accordion.Caption>
              </div>
            </Accordion.Trigger>
            <Accordion.Content>
              Tracking details arrive by email once the parcel ships.
            </Accordion.Content>
          </Accordion.Item>
        ))}
      </Accordion>
    </div>
  );
}

States

Hover, press and focus are live. disabled on an item locks that section and keeps it in its current open or closed state; on the root it locks them all. Arrow keys skip disabled triggers.

tsx
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

export default function AccordionStates() {
  return (
    <div className="gap-ws-11 grid w-full grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]">
      {[false, true].map((contained) => (
        <Accordion key={String(contained)} type="single" collapsible contained={contained}>
          <Accordion.Item value="profile">
            <Accordion.Trigger>Profile</Accordion.Trigger>
            <Accordion.Content>Name, photo and contact details.</Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="billing" disabled>
            <Accordion.Trigger>Billing</Accordion.Trigger>
            <Accordion.Content>Only owners can change billing.</Accordion.Content>
          </Accordion.Item>
          <Accordion.Item value="security">
            <Accordion.Trigger>Security</Accordion.Trigger>
            <Accordion.Content>Password and two-step sign-in.</Accordion.Content>
          </Accordion.Item>
        </Accordion>
      ))}
    </div>
  );
}

API reference

Accordion

NameDescriptionDefault
contained

Whether the accordion items are contained in separate cards. - `true` — each item wrapped in a bordered card - `false` | undefined — items separated by dividers only

boolean
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
headingLevel

Heading level for the item triggers. Match the surrounding section. Defaults to `3`.

2 | 3 | 4 | 5 | 6
3
Every other prop of Radix Accordion.Root is passed through to it. See Radix Accordion.Root.

Accordion.Caption

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Accordion.Content

No props of its ownIt takes its content as children.
Every other prop of Radix Accordion.Content is passed through to it. See Radix Accordion.Content.

Accordion.Icon

NameDescriptionDefault
icon*

The Icon that will be used within the accordion trigger

RemixiconComponentType
—
children—

Accordion.Item

No props of its ownIt takes its content as children.
Every other prop of Radix Accordion.Item is passed through to it. See Radix Accordion.Item.

Accordion.Title

No props of its ownIt takes its content as children.
Every other prop of <div> is passed through to it. See MDN: <div>.

Accordion.Trigger

No props of its ownIt takes its content as children.
Every other prop of Radix Accordion.Trigger is passed through to it. See Radix Accordion.Trigger.

Accessibility

  • Radix gives the button, aria-expanded, aria-controls and arrow-key navigation.
  • Title and caption both form the trigger’s accessible name; keep the caption short.
  • Accordion.Icon is hidden from screen readers.
  • Each trigger button sits inside a heading so users can navigate between sections by heading.
PartRendersDescription
AccordionRadix Accordion.RootCollapsible sections with single or multiple expanded items.
Accordion.Caption<div>Secondary text rendered under the title.
Accordion.ContentRadix Accordion.ContentThe content surface rendered within `Accordion`.
Accordion.Icon—An icon rendered within `Accordion`.
Accordion.ItemRadix Accordion.ItemAn individual item within `Accordion`.
Accordion.Title<div>The trigger's main text.
Accordion.TriggerRadix Accordion.TriggerThe control that opens or toggles the associated content.

Orders leave the warehouse within two business days.

tsx
import { Accordion } from '@/components/ui/wideset/accordion/Accordion';

<Accordion type="single" collapsible defaultValue="shipping">
  <Accordion.Item value="shipping">
    <Accordion.Trigger>Shipping</Accordion.Trigger>
    <Accordion.Content>Orders leave the warehouse within two business days.</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="returns">
    <Accordion.Trigger>Returns</Accordion.Trigger>
    <Accordion.Content>Send anything back within 30 days of delivery, free of charge.</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="warranty">
    <Accordion.Trigger>Warranty</Accordion.Trigger>
    <Accordion.Content>Every device we sell is covered for two years.</Accordion.Content>
  </Accordion.Item>
</Accordion>

Appearance

Contained

Content

Trigger

State

Disabled

Behavior

Open at once