Header

A site header is one row of one square with a square of room around it: the brand at the start, in twelve squares as a page’s navigation column is, so the links stand over the work; the navigation two squares after it; the actions at the end. Every link is one square high, a square apart, in the text’s ink. The page you are on (aria-current="page") stands on a hairline of the full ink, the others show a faint one under the pointer.

Below thirty squares of width the navigation and actions fold away. A menu button, an icon button in the row’s last square, opens them over the whole screen, Overlay’s screen type on the page’s paper, its close button where the menu button stood, the links one square each. While it is open, Tab and Shift+Tab go round its controls and never leave it, Escape, the close button, a link or the screen widening close it, and the page behind holds its scroll and gets it back as it was. Closing returns focus to the menu button.

An exhibition header

A short identity, navigation and a single action share the top row.

A site header

Make the preview narrower than thirty squares to fold the links into the drawer: Escape, the close button or a link closes it.

<ds-header brand="Name" literal>
<a href="/">Home</a>
<a href="/help">Help</a>
<ds-button slot="actions" primary href="/download">Download</ds-button>
</ds-header>

The links are the page’s own <a href> elements, in the page, so they render without scripts and a search engine reads them. Unless one is marked, the link to the address being read gets aria-current="page". The menu button is named with the shared word “Menu” and the overlay’s close button with “Close”, in the page’s language. ds-header-menu reports the overlay opening and closing (detail.open); openMenu() and closeMenu() work it from code.

AttributeTypeDefaultWhat it does
brandstringEmptyThe site’s name, a link home: a translation key, or the words with literal.
hrefstring/Where the brand links.
labelstringEmptyThe navigation’s accessible name, when a page has more than one.
literalbooleanfalseShow brand and label as written.
stickybooleanfalseStay at the top of the page as it scrolls, on the paper.
SlotWhat it holds
DefaultThe navigation’s links.
brandA brand of the page’s own: a logo, one square high.
actionsButtons or links at the end of the row.

attachOverlay() from 0-face/attach-overlay.ts is the mechanism the header and ds-page drawer share. Give it the toggle and the parts it folds away; it opens them in a dialog.ds-overlay.ds-overlay--screen (drawn by drawer.css) and puts them back on closing.

import { attachOverlay } from "/ds1/0-face/attach-overlay.ts";
const menu = attachOverlay({ toggle, content: [nav], closeLabel: "Close" });
import { Header } from "./design/react/header";
<Header brand="Name" literal>
<a href="/">Home</a>
<a slot="actions" className="ds-button ds-button--primary" href="/download">Download</a>
</Header>

The adapter does not register the element: import 4-page/ds-header once in the browser entry. Sync 1 copies react/header.ts when a product names header in its components.

Footer · Document · Layout · Overlay