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
| Prop | Type | Default | Description |
|---|---|---|---|
sections required |
SideNavSection[] |
- | |
footer |
ReactNode |
- | Bottom of the sidebar, e.g. the signed-in user. |
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 hasaria-current="page".
Generated from src/components/SideNav.tsx. Something wrong or missing? Open an issue.