Components/Data Display
Collapsible sections with smooth height animation.
Installation#
npx shadcn@latest add https://get-neonkit.vercel.app/r/accordion.jsonUsage#
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
<Accordion defaultValue="free">
<AccordionItem value="free">
<AccordionTrigger>Is NeonKit free?</AccordionTrigger>
<AccordionContent>Yes. Every component is MIT licensed.</AccordionContent>
</AccordionItem>
</Accordion>Examples#
Multiple
type="multiple" lets any number of sections stay open, like a filter panel.
Controlled
Drive value from state to expand or collapse everything at once.
Only the packages a component imports. For Accordion that is motion and lucide-react.
npm install motion lucide-reactAPI reference#
Accordion
Renders a div and accepts every native div attribute.
| Prop | Type | Default |
|---|---|---|
type | "single" | "multiple"How many items can be open at once. | "single" |
defaultValue | string | string[]Initially open item(s) when uncontrolled. A string for single, an array for multiple. | — |
value | string | string[]Open item(s) when controlled. "" means none in single mode. | — |
onValueChange | (value: string | string[]) => voidCalled with the new value, typed to match type. | — |
collapsible | booleanSingle only. Lets the open item close again. | true |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
AccordionItem
Renders a div. Items are separated by hairlines.
| Prop | Type | Default |
|---|---|---|
value | stringUnique id for the item. | — |
disabled | booleanLocks the item in its current state. | false |
AccordionTrigger, AccordionContent
The trigger is a button inside an h3; the content is a div that animates its height.
| Prop | Type | Default |
|---|---|---|
className | stringMerged with the defaults. | — |
Accessibility#
- Each trigger is a real button with aria-expanded and aria-controls, wrapped in an h3.
- Content has role="region" and is labelled by its trigger.
- Up and Down arrows move between triggers; Home and End jump to the first and last.
- When collapsible is false, the open trigger reports aria-disabled so screen readers know it cannot close.
- Height and opacity animations are skipped when the user prefers reduced motion.