Accordion
Height-animated disclosure with a diamond marker that morphs between states.
Live — this one is real
Usage
import { Accordion, AccordionItem } from "mizu-ui";
export function Faq() {
return (
<Accordion>
<AccordionItem value="a" title="First question">
The answer, revealed with a 450ms expo height animation.
</AccordionItem>
</Accordion>
);
}
Source & setup
Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.
npx shadcn@latest add 0xuser64bit/mizu/accordionEvery component imports from its own path, its name in kebab case. To paste the example, replace its mizu-ui import with:
import { Accordion, AccordionItem } from "@/components/ui/mizu/accordion";For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Requires React and Motion. A Client Component: its source starts with “use client”.
Inspect composite/Accordion.tsx
Source is included in the npm package under src/composite/Accordion.tsx.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| allowMultiple | boolean | false | Allow several items open at once. |
| value / defaultValue / onValueChange | string[] | [] | The open items: controlled when value is given, otherwise starting from defaultValue. |
| level | 2 | 3 | 4 | 5 | 6 | 3 | Heading level of each item, to fit the page's outline. |
| AccordionItem value | string | — | Item identity. |
| AccordionItem title | string | — | Item heading. |
Accessibility
Each title is a heading at the chosen level holding a native button with aria-expanded and aria-controls; the panel is a labelled region.
Motion
450ms expo height animation; the marker rotates 45°→0° and scales down when open.