Krizaka UI
Krizaka UI
Composants

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.

WebBêtaNavigation

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.Family on 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 tailwindcss

Styles

@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.

Krizaka

A rich menu

Two columns of links with icons whose node lights up, the current page tinted.

Krizaka

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.

PropTypeDéfautDescription
labelrequisstring—The accessible name of the navigation (“Main”) — passed translated.
compactAfternumber | false24Pixels of scroll after which the bar tightens (denser, lower, lifted). false: never.
floatingbooleantrueA 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.

PropTypeDéfautDescription
asChildboolean—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.

PropTypeDéfautDescription
currentrequisSiteId—The site this bar belongs to (@krizaka/ui/sites): marked in the family, aria-current="true".
classNamestring—Classes of the switcher (or, inside NavBar.Mobile, of the family's group).
defaultOpenboolean—Opens the panel at first render (a story, a screenshot).
labelsFamilyLabelsfamilyLabels.enThe 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.

PropTypeDéfautDescription
envstring—The environment, when it is not production (DEV).
versionstring—The version the site runs (1.2.3, shown v1.2.3).

NavBarLink

A link of the bar. asChild renders your router's <Link>.

PropTypeDéfautDescription
activeboolean—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.

PropTypeDéfautDescription
childrenrequisReactNode—The menu's links (NavBar.MenuLink), laid out in a panel; columns sets the grid.
labelrequisstring—The trigger's words (“Products”) — passed translated.
activeboolean—The current page is inside this menu: the light rests on its trigger.
columns1 | 21Columns of the panel.

NavBarMenuLink

A link inside a menu: an icon, a name and a line of text.

PropTypeDéfautDescription
titlerequisstring—The link's name — passed translated.
activeboolean—The current page.
descriptionstring—One line under it — passed translated.
iconReactNode—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.

PropTypeDéfautDescription
labelrequisstring—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.

PropTypeDéfautDescription
closeLabelrequisstring—The toggle's name when open (“Close the menu”) — passed translated.
openLabelrequisstring—The toggle's name when closed (“Open the menu”) — passed translated.

NavBarMobileLink

A link of the mobile panel.

PropTypeDéfautDescription
activeboolean—The current page.
asChildboolean—Renders your router's <Link>.

Accessibilité

  • A nav named by label, a list of links and menu triggers (Radix NavigationMenu): aria-expanded and aria-controls on each trigger.
  • The mobile panel is a disclosure (no focus trap): its toggle is named by openLabel / closeLabel and says aria-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 nav named by labels.family; its chevron is a button with the same name, aria-expanded and aria-controls. Each group is a list named by its heading, the current site says aria-current="true" and “You are here”, a site not released says its status in words.
  • NavBar.Repo is an icon link named by label; NavBar.Badge is plain text (DEV · v1.2.3), hidden below sm.

Clavier

TouchesAction
TabMoves between the brand, the items and the actions; leaving an open menu closes it.
Enter / Space / ↓Opens a menu and moves into it.
↑ / ↓ · Home / EndWalks the links of an open menu.
← / →Moves between the items of the bar.
EscCloses 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 asChild on NavBar.Link, NavBar.MenuLink and NavBar.MobileLink.
  • One primary action at most in NavBar.Actions (a Button size="sm" shape="pill").
  • Wrap it in a sticky top-3 (floating) or sticky top-0 container to keep it on screen.
  • Three zones on every Krizaka site: who I am (NavBar.Brand + NavBar.Family current="<site>", then NavBar.Badge with the version or DEV · 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.Family as the last child of NavBar.Mobile: below md the family is the panel's last group.
  • Pass the family's words translated: labels={familyLabels[locale]} from @krizaka/ui/sites.

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

Sur cette page