Built on Radix UI Accordion
Accordion
Vertically stacked, collapsible sections. Heights animate smoothly, and the icon either rotates or twitches its ears.
Playground
Yes, every primitive is built on Radix UI and tested with axe-core.
<ChibiAccordion type="single" collapsible>
<ChibiAccordionItem value="item-0">
<ChibiAccordionTrigger icon="ears">
Is it accessible?
</ChibiAccordionTrigger>
<ChibiAccordionContent>Yes, every primitive is built on Radix UI and tested with axe-core.</ChibiAccordionContent>
</ChibiAccordionItem>
<ChibiAccordionItem value="item-1">
<ChibiAccordionTrigger icon="ears">
Can I theme it?
</ChibiAccordionTrigger>
<ChibiAccordionContent>All colours are CSS variables, scoped per subtree with data-chibi-theme.</ChibiAccordionContent>
</ChibiAccordionItem>
</ChibiAccordion>Import
import {
ChibiAccordion,
ChibiAccordionItem,
ChibiAccordionTrigger,
ChibiAccordionContent,
} from '@chibi-ui/react/accordion';Examples
<ChibiAccordion type="multiple" defaultValue={['shipping']}>
<ChibiAccordionItem value="shipping">
<ChibiAccordionTrigger headingLevel={2}>Shipping</ChibiAccordionTrigger>
<ChibiAccordionContent>Free over ¥3000.</ChibiAccordionContent>
</ChibiAccordionItem>
<ChibiAccordionItem value="returns">
<ChibiAccordionTrigger headingLevel={2}>Returns</ChibiAccordionTrigger>
<ChibiAccordionContent>Within 30 days.</ChibiAccordionContent>
</ChibiAccordionItem>
</ChibiAccordion>Accessibility
- Each trigger is a button with aria-expanded inside a heading. Set the heading level with headingLevel.
- Arrow keys, Home and End move between triggers.
- Panels are regions labelled by their trigger.
- The height animation uses CSS keyframes driven by the measured content height, and is removed under reduced motion.
API reference
ChibiAccordion
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'single' | 'multiple' | — | One or many open items. |
| collapsible | boolean | — | Allow closing the open item (type='single'). |
| value / defaultValue | string | string[] | — | Controlled / uncontrolled value. |
ChibiAccordionTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | Wrapping heading level. |
| icon | 'chevron' | 'ears' | 'chevron' | Indicator style. |