Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Navigation

SideNav

Vertical app navigation for dashboards. Put it in a Drawer on phones.

import { SideNav } from "@stylhero/ui";

Example

Code
import { Badge, SideNav, Text } from "@stylhero/ui";

function SideNavExample() {
  return (
    <div style={{ height: 320, display: "flex" }}>
      <SideNav header={<Text variant="strong">Stylhero</Text>} sections={[
        { items: [{ label: "Overview", href: "#", active: true }, { label: "Builds", href: "#", badge: <Badge tone="primary">3</Badge> }] },
        { title: "Settings", items: [{ label: "Account", href: "#" }, { label: "Billing", href: "#" }] },
      ]} />
    </div>
  );
}

Props

PropTypeDefaultDescription
sections required SideNavSection[] -
header ReactNode - Top of the sidebar, e.g. the logo.

Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).

Types

type SideNavSection = { title?: ReactNode; items: SideNavItem[] };

type SideNavItem = { label: ReactNode; href: string; icon?: ReactNode; active?: boolean; /** Count or Badge on the right. */ badge?: ReactNode };

Accessibility

  • A labelled <nav>; the active item has aria-current="page".

Generated from src/components/SideNav.tsx. Something wrong or missing? Open an issue.