Components
SiteNavbar
Unstable: a website's main navigation, the brand, the links and the actions, as a full-width bar or a floating glass pill; below 768 px the links fold into a menu. Import it from @nizivo/react/unstable/site-navbar.
Examples
Basic
Two styles: the full-width bar, and the floating pill for over a hero.
import type { JSX } from 'react';
import { Button } from '@nizivo/react/button';
import { Link } from '@nizivo/react/unstable/link';
import { SiteNavbar } from '@nizivo/react/unstable/site-navbar';
const LINKS = [
{ label: 'Product', href: '/product/' },
{ label: 'Components', href: '/docs/components/', current: true },
{ label: 'Docs', href: '/docs/' },
{ label: 'Pricing', href: '/pricing/' },
];
export function SiteNavbarExample(): JSX.Element {
return (
<div style={{ display: 'grid', gap: 24, inlineSize: 960 }}>
<SiteNavbar
brand={<Link href="/">Nizivo</Link>}
links={LINKS}
actions={
<>
<Button variant="tertiary">Sign in</Button>
<Button variant="primary">Get started</Button>
</>
}
/>
<SiteNavbar
variant="floating"
brand={<Link href="/">Nizivo</Link>}
links={LINKS}
actions={<Button variant="primary">Get started</Button>}
/>
</div>
);
}
Import
import { SiteNavbar } from '@nizivo/react/unstable/site-navbar';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/site-navbar.css';Static or interactive
Server. No client JavaScript: the narrow menu is a native <details> disclosure.
How to choose.
Use
It is a <header> holding a <nav> named "Main". links (a label, an href, and current for
the page you are on, which gets aria-current="page") sit between brand and actions. variant
is bar, full width with a rule under it, or floating, a glass pill for over a hero. Below 768 px
the links move into a menu button named "Menu" whose panel opens under the bar.
Props
Server component Renders data-slot="site-navbar" with the class nz-site-navbar. Props: SiteNavbarProps. Source: src/unstable/site-navbar/site-navbar.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
actions | ReactNode | – | At the end: Sign in, Get started. |
brand | ReactNode | – | The logo, as a link home. |
labels | Partial<SiteNavbarLabels> | – | |
linksrequired | readonly SiteNavbarLink[] | – | |
render | RenderProp<Record<string, never>> | – | Must render a |
variant | "bar" | "floating" | 'bar' | The look: a full-width bar or a floating one. |
- Also takes every attribute of
<header>exceptchildren. (Omit<ComponentPropsWithRef<"header">, "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
SiteNavbarLabelstypeimport type { SiteNavbarLabels } from '@nizivo/react/unstable/site-navbar'SiteNavbar's own strings (§16.4): serialisable, English defaults.
Name Type Default Description labelrequiredstring'Main'The nav's name.
menurequiredstring'Menu'The menu button's name, below 768 px.
SiteNavbarLinktypeimport type { SiteNavbarLink } from '@nizivo/react/unstable/site-navbar'One link.
Name Type Default Description currentboolean– The page this link goes to is the current one.
hrefrequiredstring– labelrequiredReactNode– SiteNavbarPropstypeimport type { SiteNavbarProps } from '@nizivo/react/unstable/site-navbar'The props of
SiteNavbar, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
site-navbar.nz-site-navbar | SiteNavbarroot (takes render) |
|
site-navbar-link.nz-site-navbar-link | SiteNavbarinner element (CSS only); interactive, focus: self | none |
site-navbar-menu.nz-site-navbar-menu | SiteNavbarinner element (CSS only); interactive, focus: self | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
This stylesheet reads no public hook.
Layers: nz.components. Classes: .nz-site-navbar, .nz-site-navbar-actions, .nz-site-navbar-brand, .nz-site-navbar-link, .nz-site-navbar-links, .nz-site-navbar-menu, .nz-site-navbar-narrow, .nz-site-navbar-panel, .nz-site-navbar-wide.
Tokens this stylesheet reads (19)
--nz-bg-surface, --nz-border-subtle, --nz-border-width-default, --nz-elevation-2, --nz-font-label-m, --nz-radius-full, --nz-radius-md, --nz-radius-xs, --nz-size-icon-md, --nz-space-1, --nz-space-10, --nz-space-2, --nz-space-3, --nz-space-4, --nz-space-5, --nz-space-6, --nz-space-8, --nz-text-primary, --nz-text-secondary
Accessibility
These parts are interactive. Each gets the focus outline and touch-action rule from @nizivo/react/css/base.css (the nz.base layer), so the floor survives a restyle:
site-navbar-link: draws the focus outline itself on keyboard focus.site-navbar-menu: draws the focus outline itself on keyboard focus.
Keyboard
To be written.
SiteFooter
Unstable: closes every page with the brand, columns of links and the legal row; narrow, it stacks. Import it from @nizivo/react/unstable/site-footer.
Skeleton
One placeholder block, always hidden from assistive technology. The region it stands in for sets aria-busy and carries visually hidden "Loading …" text (§16.5). There is no style prop path: size it with a class, or with --nz-skeleton-width, --nz-skeleton-height and --nz-skeleton-radius.