Nav bar
The Krizaka navigation bar, the same on every site of the family: a floating pill that tightens as the page scrolls, the family switcher on the brand, one light that glides to the item under the pointer or the focus and rests on the current page, accessible menus with rich links, and a mobile panel.
Web uniquement — React, depuis @krizaka/ui/nav-bar. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Used by Orazaka, krizaka.com.
Quand l’utiliser
- The top navigation of a site or a product: a brand, a few links, one or two menus, actions on the right.
- A section bar inside an app (
floating={false}): videos, earnings, auctions. - Every site of the Krizaka family (www, ui., java., dev.<product>, admin.<product>): the brand and
NavBar.Familyon the left, at most four of the site's sections in the middle, the tools on the right.
Quand ne pas l’utiliser
- To switch views inside a page without changing the address.À la place : Tabs
- For a list of actions on one object.À la place : Dropdown menu
- For search and commands across the app.À la place : Command
- To link to another site of the family from the bar's middle: the family switcher holds them.À la place : Sites
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { NavBar } from "@krizaka/ui/nav-bar";Exemples
www.krizaka.com
The company's bar: the mark and the family switcher, Products · Open source · Our story, the repository and Contact. Open the chevron: every site of Krizaka, grouped, the current one marked.
ui.krizaka.com
Krizaka UI: the family, the version of the packages, Get started · Foundations · Components · Templates, the repository.
java.krizaka.com
Krizaka Java: the family, the version of the building blocks, Get started · Building blocks · Guides.
dev.<product>
A product's site: its mark and the family, DEV · v1.2.3, How it works · Demo · Docs, and “Talk to us” on krizaka.com while sign-up is closed.
admin.<product>
A console: the mark, the family and DEV, no sections, a full-width bar.
A site's bar
Brand, a Products menu, links, a call to action, a mobile panel — hover the items: one light glides between them.
A rich menu
Two columns of links with icons whose node lights up, the current page tinted.
Inside an app
floating={false}: a full-width bar with a hairline, for an app's sections.
Props
NavBarRoot
The bar. Place it in a sticky top-3 (floating) or sticky top-0 wrapper — or let it scroll.
| Prop | Type | Défaut | Description |
|---|---|---|---|
labelrequis | string | — | The accessible name of the navigation (“Main”) — passed translated. |
compactAfter | number | false | 24 | Pixels of scroll after which the bar tightens (denser, lower, lifted). false: never. |
floating | boolean | true | A floating pill (the Krizaka bar) or a full-width bar with a hairline under it. |
NavBarBrand
The brand: a mark and a name, linking home.
| Prop | Type | Défaut | Description |
|---|---|---|---|
asChild | boolean | — | Renders your link (a router <Link>) with the brand's look. |
NavBarFamily
The family switcher, attached to the brand (place it right after NavBar.Brand): a chevron that opens every site of
Krizaka grouped — Krizaka · Products · Open source · GitHub — the current one marked. It opens on click, Enter, Space
or ↓ (never on hover); ↑ ↓ walk the sites, Escape closes and returns the focus. Hidden below md: place a second
NavBar.Family as the last child of NavBar.Mobile, where it renders as the panel's last group.
| Prop | Type | Défaut | Description |
|---|---|---|---|
currentrequis | SiteId | — | The site this bar belongs to (@krizaka/ui/sites): marked in the family, aria-current="true". |
className | string | — | Classes of the switcher (or, inside NavBar.Mobile, of the family's group). |
defaultOpen | boolean | — | Opens the panel at first render (a story, a screenshot). |
labels | FamilyLabels | familyLabels.en | The family's words, passed translated: familyLabels.fr from @krizaka/ui/sites, or your own of the same shape. |
NavBarBadge
A small mono badge beside the brand: the environment and the version (DEV · v1.2.3). Hidden below sm.
| Prop | Type | Défaut | Description |
|---|---|---|---|
env | string | — | The environment, when it is not production (DEV). |
version | string | — | The version the site runs (1.2.3, shown v1.2.3). |
NavBarLink
A link of the bar. asChild renders your router's <Link>.
| Prop | Type | Défaut | Description |
|---|---|---|---|
active | boolean | — | The current page: aria-current="page", and the light rests on it. |
NavBarMenu
A menu of the bar: its trigger, and its links in a panel that opens under the bar.
| Prop | Type | Défaut | Description |
|---|---|---|---|
childrenrequis | ReactNode | — | The menu's links (NavBar.MenuLink), laid out in a panel; columns sets the grid. |
labelrequis | string | — | The trigger's words (“Products”) — passed translated. |
active | boolean | — | The current page is inside this menu: the light rests on its trigger. |
columns | 1 | 2 | 1 | Columns of the panel. |
NavBarMenuLink
A link inside a menu: an icon, a name and a line of text.
| Prop | Type | Défaut | Description |
|---|---|---|---|
titlerequis | string | — | The link's name — passed translated. |
active | boolean | — | The current page. |
description | string | — | One line under it — passed translated. |
icon | ReactNode | — | An icon (a signature icon of @krizaka/icons: its node lights up on hover). |
NavBarRepo
The site's repository on GitHub, an icon link of NavBar.Actions.
| Prop | Type | Défaut | Description |
|---|---|---|---|
labelrequis | string | — | The link's accessible name (“Source on GitHub”) — passed translated. |
NavBarMobile
Below md: a toggle, and a panel under the bar with its links (NavBar.MobileLink). A disclosure: Escape and a click
on a link close it, the focus returns to the toggle.
| Prop | Type | Défaut | Description |
|---|---|---|---|
closeLabelrequis | string | — | The toggle's name when open (“Close the menu”) — passed translated. |
openLabelrequis | string | — | The toggle's name when closed (“Open the menu”) — passed translated. |
NavBarMobileLink
A link of the mobile panel.
| Prop | Type | Défaut | Description |
|---|---|---|---|
active | boolean | — | The current page. |
asChild | boolean | — | Renders your router's <Link>. |
Accessibilité
- A
navnamed bylabel, a list of links and menu triggers (Radix NavigationMenu):aria-expandedandaria-controlson each trigger. - The mobile panel is a disclosure (no focus trap): its toggle is named by
openLabel/closeLabeland saysaria-expanded. - The light, the chevron and the tightening do not move under
prefers-reduced-motion; the current page is tinted before scripts load. - The family is its own
navnamed bylabels.family; its chevron is a button with the same name,aria-expandedandaria-controls. Each group is a list named by its heading, the current site saysaria-current="true"and “You are here”, a site not released says its status in words. NavBar.Repois an icon link named bylabel;NavBar.Badgeis plain text (DEV · v1.2.3), hidden belowsm.
Clavier
| Touches | Action |
|---|---|
| Tab | Moves between the brand, the items and the actions; leaving an open menu closes it. |
| Enter / Space / ↓ | Opens a menu and moves into it. |
| ↑ / ↓ · Home / End | Walks the links of an open menu. |
| ← / → | Moves between the items of the bar. |
| Esc | Closes the menu, the family or the mobile panel and returns the focus to its trigger. |
| Enter / Space / ↓ (family) | Opens the family from its chevron; ↑ / ↓ walk the sites. It never opens on hover. |
Bonnes pratiques
- Five items at most on the bar; group the rest in a menu, each link with a name and one line (
NavBar.MenuLink). - Mark the current page with
active: the light rests on it,aria-current="page"says it. - Use your router's link with
asChildonNavBar.Link,NavBar.MenuLinkandNavBar.MobileLink. - One primary action at most in
NavBar.Actions(aButtonsize="sm"shape="pill"). - Wrap it in a
sticky top-3(floating) orsticky top-0container to keep it on screen. - Three zones on every Krizaka site: who I am (
NavBar.Brand+NavBar.Family current="<site>", thenNavBar.Badgewith the version orDEV · v1.2.3), this site (at most four sections, never a link to another site), tools (search when there is something to search,NavBar.Repo, theme, language, one primary action). - Place a second
NavBar.Familyas the last child ofNavBar.Mobile: belowmdthe family is the panel's last group. - Pass the family's words translated:
labels={familyLabels[locale]}from@krizaka/ui/sites.
Composants liés
Générée depuis le code de @krizaka/ui 3.9.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub