Talisman LogoTalisman Logo Design System
Browse documentation
Components

Sidebar

The column of the primary navigation, a container and its icon items, that the application frame expands, collapses and opens on small viewports.

Stableimport { SidebarContainer } from "@repo/ui/sidebar";Source

Hover or focus an icon to see its name. The item for the current page has the primary fill.

The links in these previews point to a section of the same page (#id). They are real anchors, so they can be focused and activated, without sending you to another page. In an app, the item wraps the app’s CustomLink with asChild.

When to use

  • For the primary navigation between the main areas of the product: Processos, Tarefas, Petições, Relatórios.
  • Inside App shell, which gives it a width, collapses it and moves it into a sheet on small viewports.

When not to use

  • Navigation inside one page. Use Tabs.
  • The path to the current page. Use Breadcrumb.
  • A menu of actions. Use a Dropdown menu or a Button menu.
  • More than about 8 entries. Group them under a heading or move rarely used ones into a page.

Anatomy

Part Role
SidebarContainer A full-height flex column. Renders an aside, or nav with as="nav". It sets no width.
SidebarItem A Button sized for icons (36px). isActive switches it from ghost to primary. Use asChild for links.

The container does not collapse or open by itself. The parent controls its width: w-14 (56px) for icons only and w-64 (256px) for icons with labels, as in the app.

Collapsed and expanded

Collapsed

Only icons. Each item needs an aria-label, and a Tooltip shows the name on hover and focus.

Expanded

Icon and label side by side. Items fill the width with className="w-full justify-start".

Behavior in the application frame

App shell wraps the sidebar and decides how it behaves:

  • On desktop (768px and wider) the sidebar is a column. It is 256px wide when expanded and 56px when collapsed, with a 300ms width transition. A button at the foot toggles it.
  • Below 768px the column is hidden. A menu button in the top bar opens the same content in a sheet from the left, 288px wide, with a close button. The content is always shown expanded in the sheet.
  • The content component calls onNavigate when an item is chosen, which closes the sheet.

The content component receives collapsed and onNavigate from the shell.

Content

  • Labels are one or two words: “Processos”, “Tarefas”, “Relatórios”.
  • Use the same noun in the sidebar and in the page title it leads to.
  • Keep the order stable between sessions. Put the most used area first.
  • Use Lucide icons with aria-hidden, and name the item through its label or aria-label.

Do and don’t

DoName every icon-only item and show its name in a tooltip.
Don'tDon't leave icon-only items without a name. A screen reader says only 'button'.

Accessibility

  • Use as="nav" so the column is a navigation landmark, and give the landmark a name through the wrapper. The container does not forward aria-label.
  • Items are Button elements, or anchors with asChild. Tab moves between them and Enter activates them (and Space for buttons).
  • Icon-only items must have an aria-label. Tooltips come from Radix Tooltip: they show on hover and keyboard focus and Escape hides them.
  • isActive sets aria-selected, which is not a valid attribute for a button or link (see Known issues). Also set aria-current="page" on the link of the current page.
  • Items are 36px tall and wide, above the 24px minimum.

Code

import { SidebarContainer, SidebarItem } from "@repo/ui/sidebar";
import { Tooltip, TooltipContent, TooltipTrigger } from "@repo/ui/tooltip";
import { FolderOpen } from "lucide-react";
import CustomLink from "components/CustomLink";

<SidebarContainer as="nav" className="items-start">
  <Tooltip>
    <TooltipTrigger asChild>
      <SidebarItem asChild isActive>
        <CustomLink aria-current="page" aria-label="Processos" href="/cases">
          <FolderOpen aria-hidden />
        </CustomLink>
      </SidebarItem>
    </TooltipTrigger>
    <TooltipContent side="right">Processos</TooltipContent>
  </Tooltip>
</SidebarContainer>;

Wrap the sidebar in a TooltipProvider.

Props

SidebarContainer
PropTypeDefaultDescription
asElementTypeasideElement rendered by `SidebarContainer`. Use `nav` when it holds the main navigation
SidebarContainer (other props)
PropTypeDefaultDescription
childrenReactNode—The items.
classNamestring—Extra classes. Alignment and layout only.
SidebarItem
PropTypeDefaultDescription
isActiveboolean—Marks the item for the current page: `primary` variant instead of `ghost`.
asChildbooleanfalseRenders the child (the app's link) instead of a button.
classNamestring—Extra classes. Use `w-full justify-start` for an expanded item.
...ButtonPropsButtonProps—Every other Button prop. `size` and `variant` are accepted but ignored (see Known issues).

Known issues

Issue Effect
SidebarItem sets size="xsIcon" and variant after spreading its props. size and variant are accepted by the type but ignored. apps/app passes size and gets no effect.
SidebarItem sets aria-selected for the active item. aria-selected is not supported on buttons or links. Assistive technology ignores the active state.
SidebarContainer does not forward props other than children, className, as and ref. A nav cannot get an aria-label, an id or a data-* attribute.
Edit this page on GitHub