Nav
Links to the sections of a tool. variant="rail": icons only, in a narrow column; give each item an aria-label and a Tooltip.
Preview
Use
import { useState } from 'react';
import { Calendar, Count, Nav, NavItem, Stack } from '@/components/ui';
import { Calendar, House, Settings, Users } from 'lucide-react';
function NavDemo() {
const [at, setAt] = useState('bookings');
const go = (id: string) => (e: MouseEvent) => {
e.preventDefault();
setAt(id);
};
return (
<Stack gap={1}>
<span className="ui-overline">Studio</span>
<Nav aria-label="Studio">
<NavItem href="#today" active={at === 'today'} onClick={go('today')}>
<House />
<span className="ui-grow">Today</span>
<Count muted={at !== 'today'}>3</Count>
</NavItem>
<NavItem href="#bookings" active={at === 'bookings'} onClick={go('bookings')}>
<Calendar />
<span className="ui-grow">Bookings</span>
<Count muted={at !== 'bookings'}>12</Count>
</NavItem>
<NavItem href="#clients" active={at === 'clients'} onClick={go('clients')}>
<Users />
<span className="ui-grow">Clients</span>
</NavItem>
<NavItem href="#settings" active={at === 'settings'} onClick={go('settings')}>
<Settings />
<span className="ui-grow">Settings</span>
</NavItem>
</Nav>
</Stack>
);
}Options
| Option | Type | What it does |
|---|---|---|
variant | "rail" | rail: icons only, in a narrow column. Left out, the items show their names. |
It also takes the 280 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Parts
What goes inside one.
Without React
The same look on any HTML, with the classes ui-nav, ui-nav-item, ui-nav--rail.
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/navigation.cssIn the examples
Small screens made with it and the rest of the kit. They work: click, type and choose in them.
Bookings
Orders
- #1187 · Noor Haddad
- #1188 · Otis Brandt
- #1189 · Yuki Tanabe
Layout: states, do and don’t
Links in the sidebar. With Next.js <Link>, use className={navItemClass} and aria-current="page". Nav variant="rail": icons only in a narrow column, the chosen one in ink; give each item an aria-label and a Tooltip.
States. Layout follows the box it is in, not the window: Split, Grid, AppShell and the site parts stack when their box is narrow, at any width of the window.
Do
- Space with
gap(Stack,Row,Grid), never with margins on children. - Put the page's sections straight on the page, under their titles; a
Cardis one thing a person picks or acts on. - Check every screen at 320, 375 and 768 px with the narrow check of rule 10.
Don't
- Don't give a box a fixed width, or a
min-heighttogether with anaspect-ratio. - Don't nest a card in a card.
- Don't put two
<main>s on a page: a screen shown inside another page takesMain as="div".