Skip to main content

Installation

npm install @kuzenbo/core

Usage

import { Accordion } from "@kuzenbo/core";

function Example() {
  return (
    <Accordion defaultValue={["item-1"]}>
      <Accordion.Item value="item-1">
        <Accordion.Header>
          <Accordion.Trigger>Is it accessible?</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>
          Yes. It adheres to the WAI-ARIA design pattern.
        </Accordion.Content>
      </Accordion.Item>
      <Accordion.Item value="item-2">
        <Accordion.Header>
          <Accordion.Trigger>Is it styled?</Accordion.Trigger>
        </Accordion.Header>
        <Accordion.Content>
          Yes. It comes with default styles that you can customize.
        </Accordion.Content>
      </Accordion.Item>
    </Accordion>
  );
}

Variants

Default

<Accordion variant="default" />

Bordered

<Accordion variant="bordered" />

Ghost

<Accordion variant="ghost" />

Props

Accordion

variant
'default' | 'bordered' | 'ghost'
default:"'default'"
The visual style variant of the accordion.
size
'xs' | 'sm' | 'md' | 'lg' | 'xl'
default:"'md'"
The size of the accordion and its children.
defaultValue
string[]
The default open items (uncontrolled mode).
value
string[]
The controlled open items.
onValueChange
(value: string[]) => void
Callback fired when the open items change.
hiddenUntilFound
boolean
Enable browser find-in-page to reveal collapsed content.

Accordion.Item

value
string
required
A unique value for this accordion item.
disabled
boolean
Whether the item is disabled.

Accordion.Trigger

className
string
Additional CSS classes to apply.

Accordion.Content

keepMounted
boolean
Keep content mounted in the DOM when collapsed.
className
string
Additional CSS classes to apply.

Advanced Patterns

Single Item Mode

<Accordion defaultValue={["item-1"]}>
  {/* Only one item can be open at a time */}
</Accordion>

Controlled State

const [openItems, setOpenItems] = useState(["item-1"]);

<Accordion value={openItems} onValueChange={setOpenItems}>
  {/* ... */}
</Accordion>

Keep Content Mounted

<Accordion.Content keepMounted>
  {/* Content stays in DOM when collapsed */}
</Accordion.Content>

Build docs developers (and LLMs) love