Sidebar
SM · 950B gzip budgetA landmark navigation column with a logical-side active indicator.
- Category
- Navigation
- Budget
- sm, single-purpose control
- External runtime
- React / React DOM only
axe fixtureSSR rendersource scanbundle budget
Preview
Live fixtureTry the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.
Install
npx shadcn@latest add https://gear5-ui.vercel.app/r/sidebar.jsonCopies the source into your project. Pulls in 1 shared registry item: cn.
New here? Set up Tailwind and import aliases first →Source & props
Edit on GitHub ↗Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.
"use client";
import { cn } from "../lib/cn";
export interface SidebarItem {
label: string;
href: string;
current?: boolean;
}
export interface SidebarProps {
items: SidebarItem[];
label?: string;
className?: string;
}
/**
* A landmark navigation column. `insetInlineStart`-based active-item styling
* (via `border-s-2`) rather than `border-l-2` — the current-item indicator
* sits on the correct edge whichever direction the sidebar's own list flows.
*/
export function Sidebar({ items, label = "Sidebar", className }: SidebarProps) {
return (
<nav aria-label={label} className={cn("flex w-56 flex-col gap-0.5 text-start", className)}>
{items.map((item) => (
<a
key={item.href}
href={item.href}
aria-current={item.current ? "page" : undefined}
className={cn(
"rounded-md border-s-2 px-3 py-2 text-sm",
item.current
? "border-blue-600 bg-blue-50 font-medium text-blue-700 dark:bg-blue-950/40 dark:text-blue-300"
: "border-transparent text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-900",
)}
>
{item.label}
</a>
))}
</nav>
);
}
What CI checks
Quality contract- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation