Vertically stacked disclosure sections on Radix Accordion, single or multiple open, with hairline dividers, a rotating plus and height animation.
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ballmac/accordion"
export default function AccordionDemo() {
return (
<Accordion type="single" collapsible defaultValue="install" className="max-w-lg">
<AccordionItem value="install">
<AccordionTrigger>Where do components get installed?</AccordionTrigger>
<AccordionContent>Into components/ballmac, so they never overwrite your shadcn/ui files.</AccordionContent>
</AccordionItem>
<AccordionItem value="theme">
<AccordionTrigger>Do I need the Ballmac theme?</AccordionTrigger>
<AccordionContent>No. Components use the standard shadcn CSS variables and follow your theme.</AccordionContent>
</AccordionItem>
<AccordionItem value="license">
<AccordionTrigger>Can I use them commercially?</AccordionTrigger>
<AccordionContent>Yes. Free components work in personal, client and commercial projects.</AccordionContent>
</AccordionItem>
</Accordion>
)
}Installation
The default, and what a Radix-style project installs.
$ pnpm dlx shadcn@latest add @ballmac/accordionInstall the dependencies.
$ pnpm add radix-ui lucide-reactCopy the source into your project.
components/ballmac/accordion.tsx// Ballmac UI: Accordion. https://ui.ballmac.com/components/accordion // Based on shadcn/ui's Accordion (MIT, Copyright (c) 2023 shadcn), restyled with hairline dividers and a rotating plus. "use client" import * as React from "react" import { Accordion as AccordionPrimitive } from "radix-ui" import { Plus } from "lucide-react" import { cn } from "@/lib/utils" type AccordionProps = React.ComponentProps<typeof AccordionPrimitive.Root> function Accordion({ className, ...props }: AccordionProps) { return <AccordionPrimitive.Root data-slot="accordion" className={cn("w-full border-y", className)} {...props} /> } type AccordionItemProps = React.ComponentProps<typeof AccordionPrimitive.Item> function AccordionItem({ className, ...props }: AccordionItemProps) { return <AccordionPrimitive.Item data-slot="accordion-item" className={cn("border-b last:border-b-0", className)} {...props} /> } type AccordionTriggerProps = React.ComponentProps<typeof AccordionPrimitive.Trigger> function AccordionTrigger({ className, children, ...props }: AccordionTriggerProps) { return ( <AccordionPrimitive.Header className="flex"> <AccordionPrimitive.Trigger data-slot="accordion-trigger" className={cn( "group flex flex-1 items-center justify-between gap-4 rounded-md py-5 text-start text-base font-medium outline-none transition-colors hover:text-foreground/80 focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50", className )} {...props} > {children} <Plus aria-hidden="true" className="size-4 shrink-0 text-muted-foreground transition-transform duration-200 ease-[var(--bm-ease-out,ease-out)] group-data-[state=open]:rotate-45 motion-reduce:transition-none" /> </AccordionPrimitive.Trigger> </AccordionPrimitive.Header> ) } type AccordionContentProps = React.ComponentProps<typeof AccordionPrimitive.Content> function AccordionContent({ className, children, ...props }: AccordionContentProps) { return ( <AccordionPrimitive.Content data-slot="accordion-content" className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down motion-reduce:animate-none" {...props} > <div className={cn("pb-5 leading-relaxed text-muted-foreground", className)}>{children}</div> </AccordionPrimitive.Content> ) } export { Accordion, AccordionItem, AccordionTrigger, AccordionContent, type AccordionProps, type AccordionItemProps, type AccordionTriggerProps, type AccordionContentProps, }Update the import paths to match your project setup.
$ pnpm dlx shadcn@latest add https://ui.ballmac.com/r/base/accordion.jsonInstall the dependencies.
$ pnpm add lucide-react @base-ui/react@^1.9.0Copy the source into your project.
components/ballmac/accordion.tsx// Ballmac UI: Accordion. https://ui.ballmac.com/components/accordion // Based on shadcn/ui's Accordion (MIT, Copyright (c) 2023 shadcn), restyled with hairline dividers and a rotating plus. "use client" import * as React from "react" import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion" import { Plus } from "lucide-react" import { cn } from "@/lib/utils" type Shared = Omit<React.ComponentProps<typeof AccordionPrimitive.Root>, "value" | "defaultValue" | "onValueChange" | "multiple" | "className"> & { className?: string } type AccordionProps = Shared & ( | { /** One item open at a time. */ type: "single" value?: string defaultValue?: string onValueChange?: (value: string) => void /** Allow the open item to be closed. Without it one item always stays open. */ collapsible?: boolean } | { type: "multiple"; value?: string[]; defaultValue?: string[]; onValueChange?: (value: string[]) => void; collapsible?: never } ) function Accordion({ className, type, value, defaultValue, onValueChange, collapsible, ...props }: AccordionProps) { // Base UI always works with lists of open items; "single" is a list of at most one, written as a plain string like before. const list = (v: string | string[] | undefined) => (v === undefined ? undefined : Array.isArray(v) ? v : v === "" ? [] : [v]) const controlled = value !== undefined const [own, setOwn] = React.useState<string[]>(list(defaultValue) ?? []) // A single accordion that is not collapsible keeps its open item open, so it needs its value held here. const keepOne = type === "single" && !collapsible const current = controlled ? list(value) : keepOne ? own : undefined return ( <AccordionPrimitive.Root data-slot="accordion" multiple={type === "multiple"} value={current} defaultValue={keepOne || controlled ? undefined : list(defaultValue)} onValueChange={(next) => { if (keepOne && next.length === 0) return if (!controlled) setOwn(next) ;(onValueChange as ((v: string | string[]) => void) | undefined)?.(type === "multiple" ? next : (next[0] ?? "")) }} className={cn("w-full border-y", className)} {...props} /> ) } type AccordionItemProps = Omit<React.ComponentProps<typeof AccordionPrimitive.Item>, "className"> & { className?: string } function AccordionItem({ className, ...props }: AccordionItemProps) { return <AccordionPrimitive.Item data-slot="accordion-item" className={cn("border-b last:border-b-0", className)} {...props} /> } type AccordionTriggerProps = Omit<React.ComponentProps<typeof AccordionPrimitive.Trigger>, "className"> & { className?: string } function AccordionTrigger({ className, children, ...props }: AccordionTriggerProps) { return ( <AccordionPrimitive.Header className="flex"> <AccordionPrimitive.Trigger data-slot="accordion-trigger" className={cn( "group flex flex-1 items-center justify-between gap-4 rounded-md py-5 text-start text-base font-medium outline-none transition-colors hover:text-foreground/80 focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50", className )} {...props} > {children} <Plus aria-hidden="true" className="size-4 shrink-0 text-muted-foreground transition-transform duration-200 ease-[var(--bm-ease-out,ease-out)] group-data-panel-open:rotate-45 motion-reduce:transition-none" /> </AccordionPrimitive.Trigger> </AccordionPrimitive.Header> ) } type AccordionContentProps = Omit<React.ComponentProps<typeof AccordionPrimitive.Panel>, "className"> & { className?: string } function AccordionContent({ className, children, ...props }: AccordionContentProps) { return ( <AccordionPrimitive.Panel data-slot="accordion-content" className="h-(--accordion-panel-height) overflow-hidden text-sm transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0 motion-reduce:transition-none" {...props} > <div className={cn("pb-5 leading-relaxed text-muted-foreground", className)}>{children}</div> </AccordionPrimitive.Panel> ) } export { Accordion, AccordionItem, AccordionTrigger, AccordionContent, type AccordionProps, type AccordionItemProps, type AccordionTriggerProps, type AccordionContentProps, }Update the import paths to match your project setup.
Usage
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@/components/ballmac/accordion"The full example is in the Code tab above.
Examples
Multiple open
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ballmac/accordion"
export default function AccordionMultiple() {
return (
<Accordion type="multiple" defaultValue={["shipping", "returns"]} className="max-w-lg">
<AccordionItem value="shipping">
<AccordionTrigger>Shipping</AccordionTrigger>
<AccordionContent>Orders ship within two business days.</AccordionContent>
</AccordionItem>
<AccordionItem value="returns">
<AccordionTrigger>Returns</AccordionTrigger>
<AccordionContent>Return anything within 30 days for a full refund.</AccordionContent>
</AccordionItem>
<AccordionItem value="warranty">
<AccordionTrigger>Warranty</AccordionTrigger>
<AccordionContent>Every product has a one-year warranty.</AccordionContent>
</AccordionItem>
</Accordion>
)
}Accessibility
| Key | Action |
|---|---|
| Enter / Space | Toggles the focused section |
| ↓ / ↑ | Moves focus between section headers |
| Home / End | Moves focus to the first or last header |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
6 tab stops, each showing a visible change when it takes focus. 3 documented keys.
Not applicable: Loading, empty and error
Does not show data or take submissions.
Passed: Automated tests
Covered by accordion.test.tsx.
For information: Footprint
0.9 KB of source (gzip) in 1 file. Installs radix-ui, lucide-react.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
Show and hide sections of content one at a time (type="single" collapsible) or several at once (type="multiple"). With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Accordion (@ballmac/accordion) to this project with the shadcn MCP, then use it where it fits.
Use it for
- FAQ sections
- Settings or docs with optional detail
- Long content where readers scan headings first
Not for
- A single show/hide toggle (use reasoning-disclosure or a Radix Collapsible)
- Navigation between views (use tabs)
Registry JSON: https://ui.ballmac.com/r/accordion.json
Credits
Based on shadcn/ui Accordion, adapted by Ballmac. Free to use in personal and commercial projects.
- Registry
- shadcn/utils
Pairs well with
Badge
A small pill label in four variants with an optional status dot and success, warning and error tones. Style links with badgeVariants().
Avatar
A Radix avatar with image and initials fallback, three sizes, an optional presence dot, and AvatarGroup for overlapping stacks with a +N overflow counter.
Button Group
Join adjacent actions into one compact control surface while retaining each button's visible keyboard focus and accessible name.
Button
A button with six variants, three sizes, a pill shape and a built-in loading state. buttonVariants() styles links the same way.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.