Componentdata1.63 KB gzipZero dependencies
Accordion
Collapsible disclosure items with smooth height transitions.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add accordionOr install the full npm package:
npm install bigbulluiUsage
tsx8 lines
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"; <Accordion defaultValue="a"> <AccordionItem value="a"> <AccordionTrigger>Question?</AccordionTrigger> <AccordionContent>Answer.</AccordionContent> </AccordionItem></Accordion>Source code
accordion.tsx + 2 helpersZero third-party dependencies (3 local files shown in tabs below).
tsxaccordion.tsx268 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils";import { inertProp } from "./lib/react-compat"; type AccordionContextValue = { openIds: string[]; toggle: (id: string) => void };const AccordionCtx = React.createContext<AccordionContextValue | null>(null); interface AccordionItemContextValue { value: string; isOpen: boolean; contentId: string; triggerId: string;}const AccordionItemCtx = React.createContext<AccordionItemContextValue | null>(null); export type AccordionProps = React.HTMLAttributes<HTMLDivElement> & {Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { Accordion } from "@/components/ui/accordion"; <Accordion />| Prop | Type | Description |
|---|---|---|
| type | "single" | "multiple" | Configures type. (Default: "single") |
| collapsible | boolean | Toggles collapsible. (Default: true) |
| value | string | string[] | Unique item identifier. |
| defaultValue | string | string[] | Initially open item value. |
| onValueChange | (value: string | string[]) => void | Callback invoked on value change. |