Skip to content

Navigation

Sidebar

A side navigation: its groups of links beside the page on a large screen, behind one button that opens and closes it on a phone.

Installation

Terminal
pnpm add @elsikora/keystone-ui-kit

Usage

Import
import { Sidebar, SidebarMenuButton } from "@elsikora/keystone-ui-kit";
docs/sidebar/default.example.tsx
import {  Sidebar,  SidebarGroup,  SidebarGroupLabel,  SidebarMenu,  SidebarMenuBadge,  SidebarMenuButton,  SidebarMenuItem,} from "@elsikora/keystone-ui-kit";
export default function SidebarDefaultExample() {  return (    <div className="max-w-[240px]">      <Sidebar label="Documentation">        <SidebarGroup>          <SidebarMenuButton href="#introduction">Introduction</SidebarMenuButton>        </SidebarGroup>        <SidebarGroup>          <SidebarGroupLabel>Start</SidebarGroupLabel>          <SidebarMenu>            <SidebarMenuItem>              <SidebarMenuButton href="#install" aria-current="page">                Install              </SidebarMenuButton>            </SidebarMenuItem>            <SidebarMenuItem>              <SidebarMenuButton href="#first-game">                <span>Your first game</span>                <SidebarMenuBadge>stub</SidebarMenuBadge>              </SidebarMenuButton>            </SidebarMenuItem>          </SidebarMenu>        </SidebarGroup>      </Sidebar>    </div>  );}

Examples

Default

The current page is the link with aria-current="page"; a router's active link sets it.

API reference

Sidebar

PropTypeDefaultDescription
labelstring-The navigation's name, and the words of its phone button.
stateLabels{ open: string; close: string }{ open: "open", close: "close" }The phone button's state words beside the label.

SidebarMenuButton

PropTypeDefaultDescription
asChildbooleanfalseDraws its one child (a router's link) in its place.
aria-current"page"-"page" marks the current page.

Notes

  • Below the large screen's width the list is behind a button that carries aria-expanded; the words open and close beside its label are not read.
  • Give the router's link to SidebarMenuButton with asChild; the kit reads only aria-current, never the router.
  • A group's SidebarGroupLabel is not a heading: it names the group's SidebarMenu (aria-labelledby), so the page's first heading stays its own h1.