Accordion
Stacked disclosures. The plus turns to a cross and the answer unfolds on a spring. Layout.
Open playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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[]
More layout components
- BentoGridMixed-size tiles that rise in as a stagger, lift on hover, with a light that trails the cursor.
- CarouselDrag or flick: slides coast then snap to centre on a spring while the neighbours shrink and dim.
- EmptyStateWhat to show when there is nothing yet. Cards fan out behind an icon, the text rises in and hovering spreads the cards.
- MasonryTiles of different heights packed into the shortest column, every column ending on the same line. They rise in one after another and glide to their new place when the column count changes.
- ReorderListA list you reorder by its grip. Neighbours slide aside on a spring, and the keyboard works too: focus the grip, press arrow up or down. Moves are announced.
- SidebarA navigation rail that folds to icons. One accent pill stretches between pages, items group under headings, and the profile row shrinks to an avatar instead of vanishing.