Skip to content

Sidebar

The account navigation: a collapsible rail on desktop and a drawer on mobile, with grouped items and a footer.

Base UI3.3 kB gzipSource Registry JSON

Sidebar playground

Props

current

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/sidebar.json

The CLI writes components/ikada/sidebar.tsx and merges the ikada theme into your CSS. It also installs the components it is built from: Tooltip. Or take it from the package: import { Sidebar, SidebarHeader, SidebarFooter, SidebarNav, SidebarItem, SidebarToggle, SidebarTrigger } from "@sproutboat/ikada";

Usage

import { Sidebar, SidebarHeader, SidebarFooter, SidebarNav, SidebarItem, SidebarToggle, SidebarTrigger } from "@/components/ikada/sidebar";

<Sidebar mode="static">
  <SidebarHeader>Sproutboat</SidebarHeader>
  <SidebarNav label="Account">
    <SidebarItem href="/" icon={<HomeIcon />}>
      Home
    </SidebarItem>
    <SidebarItem href="/sprouts" icon={<FolderIcon />} current trailing={<Badge>4</Badge>}>
      Sprouts
    </SidebarItem>
    <SidebarItem href="/logs" icon={<LogsIcon />}>
      Logs
    </SidebarItem>
  </SidebarNav>
</Sidebar>

Examples

Column

On desktop a 240px column with a header, a flat nav and an optional footer.

Rail

Collapses to a 56px icon rail. Labels stay as accessible names and show in a tooltip.

Drawer

On narrow screens it is a modal drawer: it traps focus, closes on Escape and returns focus to the trigger.

Props

SidebarProps
PropTypeDescription
childrenrequiredReactNodeSidebar content: a header, nav and footer.
mode"auto" | "static" | "drawer"`static` is always a column, `drawer` is always an overlay, `auto` switches at 768px. Default `auto`.
collapsedbooleanIcon-only rail (desktop only). Controlled. Default `false`.
openbooleanMobile drawer state. Controlled. Default `false`.
onOpenChange((open: boolean) => void)Called with the new open state when it opens or closes.
drawerLabelstringAccessible name of the drawer dialog. Default `Navigation`.

Also takes every prop of Omit<ComponentProps<"aside">, "children">.

SidebarItemProps
PropTypeDescription
hrefstringPlain destination. With a router, leave it out and pass `render={<RouterLink to="/x" />}`.
iconReactNodeIcon before the label.
currentbooleanMarks the page you are on: `aria-current="page"` and a raised fill. Default `false`.
trailingReactNodeTrailing text or a Badge, hidden in the rail.
childrenrequiredstringThe item's label.
renderReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
classNamestringClasses merged onto the root element, after ikada's own.

Also takes every prop of WithClass<Omit<useRender.ComponentProps<"a">, "children">>.

SidebarNavProps
PropTypeDescription
labelstringDefault `Account`.
SidebarToggleProps
PropTypeDescription
collapsedrequiredboolean—
onCollapsedChangerequired(collapsed: boolean) => void—
SidebarTriggerProps
PropTypeDescription
labelstringDefault `Open navigation`.

Source: src/components/sidebar.tsx