- Docs
- Components
- Console frame
Sidebar
A console's navigation: links only, in groups, one level of nesting, every item in the Tab order.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.4
- Renders
<nav>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// Experimental: from the package's experimental entry, until it's stable.
import { Sidebar, SidebarGroup, SidebarItem } from "@qeetrix/react/experimental";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
label | string | required | Names the navigation landmark: "Qeet ID". |
title | ReactNode | — | The area's heading: "Identity". |
filter | boolean | false | "Filter navigation": narrows the items as you type. |
footer | ReactNode | — | Below the items: help, what's new. |
SidebarGroup: label | ReactNode | — | Without one, space alone separates it. |
SidebarItem: label | string | required | The text; in the rail, the tooltip. |
SidebarItem: href · render | string · ReactElement | — | Where it goes; a router link. |
SidebarItem: icon · filledWhenCurrent | IconSource · boolean | — · true | A 16px round icon, filled while current; false keeps the outline. An icon with no filled drawing keeps its outline. |
SidebarItem: current | boolean | false | aria-current="page" and the Ember bar. |
SidebarItem: badge | ReactNode | — | A count or a Badge at the end. |
SidebarItem: disabled | boolean | false | Greyed, out of the Tab order; aria-disabled. |
SidebarItem: children · defaultOpen | SidebarItem[] · boolean | — · holds the current | One level of items: a category, open when it holds the current page. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
sidebar | <div> | The column. |
sidebar-nav | <nav> | The landmark, named by label. |
sidebar-group | <div> | A group, between hairlines. |
sidebar-group-label | <div> | Its label. |
sidebar-item | <li> | An item: its link, or a category's button. |
sidebar-item-badge | <span> | The count. |
04
With your router
render takes the router's link; current comes from the route.
const { pathname } = useLocation();
<SidebarItem label="Users" href="/users" render={<Link to="/users" />} current={pathname.startsWith("/users")} icon={UsersIcon} />