Skip to Content
zjkm-ui
Components

Indicator Sidebar

A sidebar whose active marker slides to the current page.

Props
<IndicatorSidebar items={items} current="#home" />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/indicator-sidebar.json
import { IndicatorSidebar } from "@/components/indicator-sidebar"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

A sidebar with a marker on its rail that slides to the current page. Pick another page in the demo to see it move.

import { IndicatorSidebar } from "@/components/indicator-sidebar";

export function OnThisPage({ active }: { active: string }) {
  return <IndicatorSidebar label="On this page" items={[{ label: "Usage", href: "#usage" }, { label: "Props", href: "#props" }]} current={active} />;
}

Props

PropTypeDefaultDescription
items{ label, href }[]The links.
currentstringThe current page's href.
labelstring"Sections"Accessible name of the nav.
classNamestringClasses for the root element.

With reduced motion, the marker jumps instead of sliding.

On this page