Menu

Sidebar

Vertical navigation + sidebar. 4 states × 2 types.

Installation

$ npx uix-ui@latest add sidebar-item

This copies the file into components/ui/sidebar-item.tsx in your project. npx shadcn@latest add @uix/sidebar-item works too.

Usage

sidebar-item.tsx
import { Sidebar, SidebarItem } from "@/components/ui/sidebar-item";

<Sidebar style={{ width: 240, maxWidth: "100%" }}>
  <SidebarItem href="#home" icon={<House />} active={here === "home"} onClick={go("home")}>Home</SidebarItem>
  <SidebarItem href="#orders" icon={<Inbox />} badge={12} active={here === "orders"} onClick={go("orders")}>Orders</SidebarItem>
  <SidebarItem href="#customers" icon={<User />} trailingChevron active={here === "customers"} onClick={go("customers")}>Customers</SidebarItem>
  <SidebarItem href="#reports" icon={<Star />} disabled>Reports</SidebarItem>
</Sidebar>

Props

PropTypeDefaultDescription
activebooleanfalseMarks the current page: sets aria-current and the active look.
disabledbooleanfalse
iconReact.ReactNode–Icon before the label.
badgeReact.ReactNode–Count or tag after the label.
trailingChevronbooleanfalseChevron at the end.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
This file exports 2 parts: Sidebar, SidebarItem. Use only the ones you need.
esc

↑↓ to navigate · ↵ to select · esc to close