Containment
Accordion
Stacked sections that open and close. The open item's tint grows from its trigger so it reads as one soft pill.
Examples and variants
Basic
One open at a time.
function AccordionBasic() {
return (
<Accordion className="w-full max-w-sm" defaultValue={["free"]}>
<AccordionItem value="what">
<AccordionTrigger>What is Isotopi?</AccordionTrigger>
<AccordionContent>A design system with its own tokens, motion and code.</AccordionContent>
</AccordionItem>
<AccordionItem value="free">
<AccordionTrigger>Is it free?</AccordionTrigger>
<AccordionContent>Yes. MIT licence.</AccordionContent>
</AccordionItem>
<AccordionItem value="themes">
<AccordionTrigger>Which themes?</AccordionTrigger>
<AccordionContent>Minimal first, then Glass, Expressive and Paper.</AccordionContent>
</AccordionItem>
</Accordion>
)
}Spec drawing
Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.
Install
With the CLI
The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/accordion.jsonBy hand
No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.
Install the packages it uses.
Terminalnpm install @base-ui/react cn lucide-reactCopy this file to the same paths in your project. Imports use the
@/alias for your project root.components/ui/accordion.tsxaccordion
components/ui/accordion.tsx"use client" import * as React from "react" import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion" import { ChevronDownIcon } from "lucide-react" import { cn } from "cn" /* Accordion: stacked sections that open and close. Height moves on --ease-sheet, content rises in just after, the chevron flips with a bounce. In Minimal the open item's tint grows from the trigger down, so an open section reads as one soft pill. No dividers between items. */ function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) { return <AccordionPrimitive.Root data-slot="accordion" className={cn("flex flex-col gap-1", className)} {...props} /> } function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) { return ( <AccordionPrimitive.Item data-slot="accordion-item" className={cn("accordion-item rounded-(--accordion-corner)", className)} {...props} /> ) } function AccordionTrigger({ className, children, ...props }: AccordionPrimitive.Trigger.Props) { return ( <AccordionPrimitive.Header className="flex"> <AccordionPrimitive.Trigger data-slot="accordion-trigger" className={cn( "flex flex-1 items-center justify-between gap-inline-md rounded-(--accordion-corner) px-(--accordion-padding-x) py-(--accordion-padding-y) text-left text-sm font-medium outline-none hover:bg-(--accordion-trigger-container-hover) active:bg-(--accordion-trigger-container-pressed) focus-visible:shadow-(--focus-ring) data-[panel-open]:hover:bg-transparent", className )} {...props} > {children} <ChevronDownIcon aria-hidden className="accordion-chevron size-icon-md shrink-0 text-muted-foreground" /> </AccordionPrimitive.Trigger> </AccordionPrimitive.Header> ) } function AccordionContent({ className, children, ...props }: AccordionPrimitive.Panel.Props) { return ( <AccordionPrimitive.Panel data-slot="accordion-content" className="accordion-panel overflow-hidden" {...props}> <div className={cn("accordion-copy px-3 pb-3 text-sm text-muted-foreground", className)}>{children}</div> </AccordionPrimitive.Panel> ) } export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
Imports
What the examples on this page import:
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"Anatomy
- 1Item · --accordion-corner; open tint --accordion-open-container.
- 2Trigger · --accordion-padding-*; chevron flips.
- 3Panel · Height animates; content rises in.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue / value | string[] | — | Open items. |
multiple | boolean | false | Allow several open. |
Tokens
Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.
| Token | Points to | Light | Dark |
|---|---|---|---|
--accordion-corner | var(--shape-md) | 14px | same |
--accordion-trigger-container-hover | var(--color-bg-hover) | oklch(0.965 0.005 95) | oklch(0.22 0 0) |
--accordion-trigger-container-pressed | var(--color-bg-pressed) | oklch(0.94 0.007 95) | oklch(0.27 0 0) |
--accordion-open-container | var(--surface-container) | oklch(0.965 0.005 95) | oklch(0.12 0 0) |
--accordion-padding-x | var(--space-3) | 12px | same |
--accordion-padding-y | var(--space-3) | 12px | same |
Motion
| Trigger | What happens | Tokens |
|---|---|---|
| Open | Height on the sheet curve; content rises; chevron flips with a bounce. | --duration-medium, --ease-sheet |
Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.
Accessibility
- Triggers are buttons with aria-expanded.
- Arrow keys move between triggers.
Usage
Do
- Use for FAQs and long settings.
Don’t
- Don't hide content people need to see.
Code
"use client"
import * as React from "react"
import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion"
import { ChevronDownIcon } from "lucide-react"
import { cn } from "cn"
/*
Accordion: stacked sections that open and close. Height moves on
--ease-sheet, content rises in just after, the chevron flips with a bounce.
In Minimal the open item's tint grows from the trigger down, so an open
section reads as one soft pill. No dividers between items.
*/
function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) {
return <AccordionPrimitive.Root data-slot="accordion" className={cn("flex flex-col gap-1", className)} {...props} />
}
function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {
return (
<AccordionPrimitive.Item
data-slot="accordion-item"
className={cn("accordion-item rounded-(--accordion-corner)", className)}
{...props}
/>
)
}
function AccordionTrigger({ className, children, ...props }: AccordionPrimitive.Trigger.Props) {
return (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
data-slot="accordion-trigger"
className={cn(
"flex flex-1 items-center justify-between gap-inline-md rounded-(--accordion-corner) px-(--accordion-padding-x) py-(--accordion-padding-y) text-left text-sm font-medium outline-none hover:bg-(--accordion-trigger-container-hover) active:bg-(--accordion-trigger-container-pressed) focus-visible:shadow-(--focus-ring) data-[panel-open]:hover:bg-transparent",
className
)}
{...props}
>
{children}
<ChevronDownIcon aria-hidden className="accordion-chevron size-icon-md shrink-0 text-muted-foreground" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
)
}
function AccordionContent({ className, children, ...props }: AccordionPrimitive.Panel.Props) {
return (
<AccordionPrimitive.Panel data-slot="accordion-content" className="accordion-panel overflow-hidden" {...props}>
<div className={cn("accordion-copy px-3 pb-3 text-sm text-muted-foreground", className)}>{children}</div>
</AccordionPrimitive.Panel>
)
}
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }