Componentdata1.63 KB gzipZero dependencies

Accordion

Collapsible disclosure items with smooth height transitions.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add accordion

Or install the full npm package:

npm install bigbullui

Usage

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 helpers

Zero 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 />
PropTypeDescription
type"single" | "multiple"Configures type. (Default: "single")
collapsiblebooleanToggles collapsible. (Default: true)
valuestring | string[]Unique item identifier.
defaultValuestring | string[]Initially open item value.
onValueChange(value: string | string[]) => voidCallback invoked on value change.