Colour theme

NavItem

  • Primitives

One item of a site's navigation: a link that takes the reader somewhere within the site, or a button that opens the next level of it. Button's shape exactly — one table, the element as the gate, two front doors — because two components sharing typography by copy is the drift a table exists to stop. It reads the nav voice as tokens; Nav, when it comes, arranges items.

NavButton

A button that opens the next level. aria-expanded is written on a button always, true or false, never on a link; aria-controls names what it opens; the icon turns when expanded. A branch that contains the current page is current too, without being the page. What the press does belongs to the host — this is the control.

astro
---
import NavButton from "tsugite/NavItem/NavButton.astro";
---
{/* A button that opens the next level. The same table as the link, gated on the element:
    aria-expanded is written on a button always (true or false), aria-controls names what
    it opens, and the icon turns when expanded. A branch that contains the current page
    is current too — without ever being the page. What the press does is the host's. */}
<NavButton icon="icon-panel-left-open" aria-controls="menu-products">Products</NavButton>
<NavButton icon="icon-panel-left-open" aria-controls="menu-company" expanded={true}>Company</NavButton>
<NavButton icon="icon-panel-left-open" aria-controls="menu-docs" current={true}>Docs</NavButton>

Sizes

Three steps of the nav voice, the same tokens a standalone Caption in the nav voice reads. In this theme the voice carries label's values; it is its own row in the token factory, so a brand can set navigation apart without moving labels.

astro
---
import NavLink from "tsugite/NavItem/NavLink.astro";
---
{/* Three steps of the nav voice — the same tokens a standalone Caption in the nav
    voice reads. */}
<NavLink href="#" size="sm">Small</NavLink>
<NavLink href="#" size="md">Medium</NavLink>
<NavLink href="#" size="lg">Large</NavLink>

The element is the gate

expanded does not exist on a link and href is not an attribute of a button: both are refused in development (ADR-0019), not dropped.

astro
---
import NavLink from "tsugite/NavItem/NavLink.astro";
import NavButton from "tsugite/NavItem/NavButton.astro";
---
{/* The element is the gate (ADR-0019). A link given `expanded` is refused: only a button
    opens a disclosure. A button given `href` is refused: a button goes nowhere. Both show
    in development and render nothing in production. */}
<NavLink href="#" expanded={true}>A link cannot expand</NavLink>
<NavButton href="#">A button goes nowhere</NavButton>

Test bench

The NavItem fixture — both front doors at three sizes, every state, current and expanded, mounted unchanged.