Skip to content
Klarhimmel UI

Accordion

Rooms are ready from 15:00.

npx shadcn add @klarhimmel/accordion

Examples

  • Faq

  • Multiple

  • Controlled

DetailsAbout, usage, props and more

A stack of headings that each open and close a panel. One open at a time, or several.

When to use

  • Use for

    A list of questions or settings groups where people read a few and skip the rest.

  • Not for

    Content everyone must read. Show it. Not for switching views. Use Tabs.

  • Pairs with

    Text, Badge, Card.

Preview

Rooms are ready from 15:00. If you arrive earlier we keep your bags at the desk.

accordion.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Accordion, AccordionItem } from '@/components/klarhimmel/ui/accordion';

export default function Example() {
  return (
    <Theme theme="brand">
      <Accordion defaultValue="checkin">
        <AccordionItem value="checkin" title="When can I check in?">From 15:00.</AccordionItem>
        <AccordionItem value="parking" title="Is there parking?">Yes, behind the building.</AccordionItem>
      </Accordion>
    </Theme>
  );
}

Import

Import

import { Accordion, AccordionItem } from '@/components/klarhimmel/ui/accordion';
Files
accordion.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
Accordion.type'single'-One panel open at a time, or any number.
Accordion.valuestring-Open item value (a string when single, a list when multiple).
Accordion.defaultValuestring-Open item value (a string when single, a list when multiple).
Accordion.onValueChange(value: string) => void-Open item value (a string when single, a list when multiple).
Accordion.collapsibleboolean-Single mode only. With false the open item cannot be closed.
Accordion.childrenReactNoderequired
Accordion.classNamestring-Extra classes, merged after the component's own.
AccordionItem.valuestringrequiredOpen item value (a string when single, a list when multiple).
AccordionItem.titleReactNoderequired
AccordionItem.level2 | 3 | 4 | 53
AccordionItem.disabledboolean-
AccordionItem.childrenReactNoderequired

Accessibility

KeyDoes
Enter / SpaceOpens or closes the focused panel
Down / UpMoves focus to the next or previous heading, wrapping
Home / EndMoves focus to the first or last heading
TabMoves on; closed panels are skipped

Each trigger sits in a heading. Choose its level so the page outline stays correct.

Accessibility