Examples

Single

One panel open at a time; closing the open one is allowed by default.

Preview

Invoices are issued monthly in arrears and payable within 30 days.

Example.tsx
import { Accordion } from '@reactloom/ui';

const faq = [
  ['billing', 'How does billing work?', 'Invoices are issued monthly in arrears and payable within 30 days.'],
  ['sso', 'Do you support single sign-on?', 'Yes — SAML 2.0 and OpenID Connect on the Enterprise plan.'],
  ['residency', 'Where is my data stored?', 'In the EU (Frankfurt) by default. US and APAC regions are available.'],
];

export default function Example() {
  return (
    <div style={{ width: '100%', maxWidth: 600 }}>
      <Accordion.Root type="single" defaultValue="billing">
        {faq.map(([value, question, answer]) => (
          <Accordion.Item key={value} value={value}>
            <Accordion.Trigger>{question}</Accordion.Trigger>
            <Accordion.Content>{answer}</Accordion.Content>
          </Accordion.Item>
        ))}
      </Accordion.Root>
    </div>
  );
}

Multiple

Any number open; headingLevel fits the page outline.

Preview

Example.tsx
import { Accordion, Switch, Stack } from '@reactloom/ui';

export default function Example() {
  return (
    <div style={{ width: '100%', maxWidth: 600 }}>
      <Accordion.Root type="multiple" defaultValue={['email']} headingLevel={4}>
        <Accordion.Item value="email">
          <Accordion.Trigger>Email notifications</Accordion.Trigger>
          <Accordion.Content>
            <Stack gap="2">
              <Switch label="Invoices" defaultChecked />
              <Switch label="Product updates" />
            </Stack>
          </Accordion.Content>
        </Accordion.Item>
        <Accordion.Item value="slack">
          <Accordion.Trigger>Slack notifications</Accordion.Trigger>
          <Accordion.Content>Connect a Slack workspace to enable these.</Accordion.Content>
        </Accordion.Item>
        <Accordion.Item value="sms" disabled>
          <Accordion.Trigger>SMS (Enterprise)</Accordion.Trigger>
          <Accordion.Content>Available on the Enterprise plan.</Accordion.Content>
        </Accordion.Item>
      </Accordion.Root>
    </div>
  );
}

API reference

Accordion.Root

Accordion.Root
PropTypeDefault
typerequired
'single' | 'multiple'—
value / defaultValue
string | null · string[]—
onValueChange
(value) => void—
collapsible
Single mode: allow closing the open panel.
booleantrue
headingLevel
2 | 3 | 4 | 5 | 63
disabled
booleanfalse

Accordion.Item

Accordion.Item
PropTypeDefault
valuerequired
string—
disabled
booleanfalse

Accordion.Trigger · Accordion.Content

Accordion.Trigger · Accordion.Content
PropTypeDefault
…
Heading button and its labelled region.
ButtonHTMLAttributes · HTMLAttributes—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

Theme tokens it reads

--pl-color-border-default

Accessibility

  • Each trigger is a button inside a heading; panels are regions labelled by their trigger.
  • Collapsed panels use hidden="until-found": find-in-page searches them and opens the match.
  • Disabled items expose aria-disabled and stay focusable so they can be discovered.
Keyboard interactions
KeyAction
Enter / SpaceToggle the focused section
↓ / ↑Next / previous header
Home / EndFirst / last header
TabInto the open panel

Usage guidelines

Do

  • Use for FAQs and long settings pages.
  • Write headers as questions or clear topics.

Don’t

  • Don’t hide content people need to compare side by side.
  • Don’t nest accordions.