Sidebar, NavSection and NavItem
import { Sidebar, NavSection, NavItem } from "@study/ui"
On the left on wide screens. On phones, the TabBar takes over.
Result
Loading...
Live Editor
<div style={{ width: 260, height: 620, border: "1.5px solid var(--ui-line)", borderRadius: 24, overflow: "hidden" }}> <Sidebar brand={<Logo />} footer={ <Card padding="sm" tone="gelb"> <strong>Claude is connected</strong> </Card> } > <NavSection> <NavItem icon="sun" label="Today" href="#" active /> <NavItem icon="grid" label="Courses" href="#" /> <NavItem icon="calendar" label="Calendar" href="#" /> <NavItem icon="search" label="Search" shortcut="⌘K" onClick={() => {}} /> </NavSection> <NavSection title="Your courses"> <NavItem dot="blau" label="Control Engineering" href="#" size="sm" /> <NavItem dot="orange" label="Engineering Mechanics" href="#" size="sm" /> <NavItem dot="violett" label="Maths III" href="#" size="sm" badge={11} /> </NavSection> </Sidebar> </div>
When to use
- At the top the fixed places with an icon, below them the courses with their colour as a dot (
dot). - A place is active when you are in it or below it (a course page belongs to "Courses" and to its course).
- At the bottom the account and the settings.
Props
| Prop | Type | Default | Meaning |
|---|---|---|---|
children * | ReactNode | – | `NavSection`s and `NavItem`s. |
brand | ReactNode | – | At the top: usually the `Logo`. |
className | string | – | |
collapsed | boolean | – | Only the icons: labels hide (they stay for screen readers and as tooltips), counts shrink to a dot. |
footer | ReactNode | – | At the bottom: the account and settings. |
label | string | uiText().mainNav |
| Prop | Type | Default | Meaning |
|---|---|---|---|
action | ReactNode | – | At the right of the heading, e.g. an `IconButton` "Create course". |
title | ReactNode | – | A small heading, e.g. "Your courses"; leave it out for the main places. |
| Prop | Type | Default | Meaning |
|---|---|---|---|
label * | ReactNode | – | |
active | boolean | – | Whether this is the current place. |
aria-expanded | boolean | – | |
aria-haspopup | "menu" | – | For a button that opens a menu. |
badge | number | – | A small count at the end. |
dot | "blau" | "petrol" | "gruen" | "gelb" | "orange" | "rot" | "violett" | "grau" | – | A subject's colour as a small square in place of an icon. |
endIcon | enum | – | An icon at the end, e.g. "settings" on the account. |
href | string | – | |
icon | enum | – | |
leading | ReactNode | – | Something else in place of an icon, e.g. an `Avatar`. |
linkAs | ElementType | – | The link element, e.g. react-router's `Link` (it gets `to`). |
onClick | MouseEventHandler<HTMLElement> | – | |
shortcut | string | – | A keyboard shortcut shown at the end, e.g. "⌘K". |
size | "sm" | "md" | md | smaller rows for long lists such as the subjects |
Accessibility
- A
nav"Hauptnavigation" (main navigation) with lists; the active place isaria-current="page". - With the router:
linkAs={NavLink}orLink–hrefbecomesto.