Nav item
In code: NavItem
A part of Nav: use it inside one.
One link in a Nav
Preview
Studio
Use
The code of the preview above
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 |
|---|---|---|
active | boolean | Marks it as the page the person is on (aria-current="page"). |
It also takes the 288 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
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.
Harbour
Studio
You
Harbour Studio
Bookings
This week41
Waiting12
No-shows1
Orders
- #1187 · Noor Haddad
- #1188 · Otis Brandt
- #1189 · Yuki Tanabe
Layout: states, do and don’t
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".