Skip to main content

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​

PropTypeDefaultMeaning
children *ReactNode–`NavSection`s and `NavItem`s.
brandReactNode–At the top: usually the `Logo`.
classNamestring–
collapsedboolean–Only the icons: labels hide (they stay for screen readers and as tooltips), counts shrink to a dot.
footerReactNode–At the bottom: the account and settings.
labelstringuiText().mainNav
PropTypeDefaultMeaning
actionReactNode–At the right of the heading, e.g. an `IconButton` "Create course".
titleReactNode–A small heading, e.g. "Your courses"; leave it out for the main places.
PropTypeDefaultMeaning
label *ReactNode–
activeboolean–Whether this is the current place.
aria-expandedboolean–
aria-haspopup"menu"–For a button that opens a menu.
badgenumber–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.
endIconenum–An icon at the end, e.g. "settings" on the account.
hrefstring–
iconenum–
leadingReactNode–Something else in place of an icon, e.g. an `Avatar`.
linkAsElementType–The link element, e.g. react-router's `Link` (it gets `to`).
onClickMouseEventHandler<HTMLElement>–
shortcutstring–A keyboard shortcut shown at the end, e.g. "⌘K".
size"sm" | "md"mdsmaller rows for long lists such as the subjects

Accessibility​

  • A nav "Hauptnavigation" (main navigation) with lists; the active place is aria-current="page".
  • With the router: linkAs={NavLink} or Link – href becomes to.