Accordion

Stacked disclosures. The plus turns to a cross and the answer unfolds on a spring. Layout.

Open playground

Animated React components built on motion, with springs instead of tweens.

About

Accordion is a React component in the Layout category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Accordion } from "@ashutoshswamy/smoui" and set items, type, defaultOpen.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Accordion } from "@ashutoshswamy/smoui";

<Accordion type="single" items={[{ id: "a", title: "What is smoui?", content: "..." }]} />

Props 3

items

Disclosures.

{ id: string; title: string; content: ReactNode }[]
type

One open at a time, or any number.

"single""multiple"default "single"
defaultOpen

Ids open at first.

string[]