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 playground
Springs carry weight, so motion feels physical instead of scripted.

About

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

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
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