Tabs
The thumb stretches to the tab, the panel slides in from the side you moved toward, and its height springs to fit. Layout.
Open playgroundAbout
Tabs 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 { Tabs } from "@ashutoshswamy/smoui" and set tabs, defaultValue.
Install
npm i @ashutoshswamy/smouiUsage
import { Tabs } from "@ashutoshswamy/smoui";
<Tabs tabs={[{ id: "a", label: "Overview", content: "..." }, { id: "b", label: "Details", content: <List /> }]} />Props 2
- tabs
Tabs and panels.
{ id: string; label: string; content: ReactNode }[]- defaultValue / onChange
Initial tab and change handler. Arrow keys switch.
string / (id: string) => void
More layout components
- AccordionStacked disclosures. The plus turns to a cross and the answer unfolds on a spring.
- 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.