Nasaq
Components

IconRailSidebar

Two-level navigation. A slim rail of icons picks the section and a sub-sidebar beside it lists that section's pages. Folds into a sheet on mobile.

PreviewOpen ↗

Code

import { Home, Users } from "lucide-react";import { IconRailSidebar } from "@fadymondy/nasaq/web";const sections = [  { id: "home", label: "Home", icon: <Home />, groups: [{ id: "g", items: [{ id: "dash", label: "Dashboard" }] }] },  { id: "people", label: "People", icon: <Users />, groups: [{ id: "g", items: [{ id: "users", label: "Users" }, { id: "roles", label: "Roles" }] }] },];export function Page() {  return (    <IconRailSidebar sections={sections} defaultValue="people" onItemSelect={(id) => console.log(id)}>      <main>Content</main>    </IconRailSidebar>  );}

Navigation · beta

Live examples and controls: IconRailSidebar in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/icon-rail-sidebar.json

The navigation frame for products with many areas. The narrow rail (icons with tooltips) holds the areas; the sub-sidebar next to it lists the pages of the chosen area, in groups, with expandable parents. Your page is children and fills the rest. On narrow screens both fold into a sheet behind a menu button.

When to use

  • Admin areas and dashboards with 4 to 8 top-level areas and several pages in each.

When not to use

  • One flat list of pages: use the AppShell sidebar.
  • Settings pages: use SettingsSections.

Import

import { IconRailSidebar } from "@fadymondy/nasaq/web";

Quick start

import { Home, Users } from "lucide-react";
import { IconRailSidebar } from "@fadymondy/nasaq/web";

const sections = [
  { id: "home", label: "Home", icon: <Home />, groups: [{ id: "g", items: [{ id: "dash", label: "Dashboard" }] }] },
  { id: "people", label: "People", icon: <Users />, groups: [{ id: "g", items: [{ id: "users", label: "Users" }, { id: "roles", label: "Roles" }] }] },
];

export function Page() {
  return (
    <IconRailSidebar sections={sections} defaultValue="people" onItemSelect={(id) => console.log(id)}>
      <main>Content</main>
    </IconRailSidebar>
  );
}

Anatomy

IconRailSidebar        data-slot="icon-rail-sidebar"
├─ rail                data-slot="icon-rail": brand, section buttons, railFooter
├─ sub-sidebar         data-slot="icon-rail-sub": title, subHeader, groups, subFooter
├─ mobile bar          data-slot="icon-rail-mobile-bar": menu button, opens a Sheet with rail and sub
└─ content             data-slot="icon-rail-content": children

API

IconRailSidebar

PropTypeDefaultDescription
sectionsRailSection[]required{ id, label, icon, href?, badge?, title?, groups? }. A section without groups is a plain link.
value, defaultValue, onValueChangestring, (id) => voidfirst sectionActive section.
activeItemstringnoneActive page id (controlled).
onItemSelect(id, sectionId) => voidnoneA page, or a section with no sub-sidebar, was chosen.
brand, railFooterReactNodenoneTop and bottom of the rail.
subHeader, subFooterReactNodenoneInside the sub-sidebar.
subOpen, defaultSubOpen, onSubOpenChangeboolean, (open) => voidopenWide-screen collapse of the sub-sidebar.
labelsIconRailSidebarLabelsen / arMenu, collapse, expand and close text.

RailGroup is { id, label?, items }; RailLink is { id, label, icon?, href?, badge?, children? }.

Examples

  • Controlled: value={section} onValueChange={setSection} activeItem={page}.
  • Links: give each RailLink an href and route in onItemSelect.
  • Arabic: pass Arabic labels; the rail moves to the inline start and mirrors.

Accessibility

KeyAction
Arrow Up / DownMove between rail buttons.
Enter / SpaceChoose the section or page.
EscapeClose the mobile sheet.

Rail buttons are named by their label (also the tooltip); the active one has aria-current. Pass labels for the menu and collapse buttons in other languages.

RTL & i18n

The rail sits at the inline start and the sub-sidebar mirrors. Built-in English and Arabic strings follow the Nasaq locale. Section and page labels are yours to translate.

Styling & tokens

Uses bg-nq-selected, bg-nq-hover, border-border, rounded-control and the sidebar item styles. Extend with className.

Do / Don't

  • Do keep the rail to a handful of areas with recognisable icons.
  • Do not put actions on the rail; it navigates.

Lab

https://docs.nasaqui.com/?path=/docs/components-navigation-icon-rail-sidebar--docs

On this page