Sidebar

A 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. Layout.

Open playground

About

Sidebar 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 { Sidebar } from "@ashutoshswamy/smoui" and set items, title, footer among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<Sidebar
  title="Studio"
  items={[
    { id: "home", label: "Home", icon: "home", section: "Workspace" },
    { id: "inbox", label: "Inbox", icon: "inbox", badge: 4 },
    { id: "team", label: "Team", icon: "users", section: "Manage" },
  ]}
  footer={(collapsed) => (collapsed ? <Avatar name="Mira Chen" /> : <ProfileRow />)}
  onChange={(id) => go(id)}
/>

Props 5

items

Icons are Heroicon names. section starts a group under that heading.

{ id; label; icon; badge?; section? }[]
title

Brand line.

ReactNode
footer

Pinned bottom slot. A function lets you show only an avatar when collapsed.

ReactNode | (collapsed: boolean) => ReactNode
value / defaultValue / onChange

Active item.

string / string / (id) => void
defaultCollapsed / height

Start folded; panel height.

boolean / numberstringdefault false / 420