Header

A site header is one row of one square with a square of room around it: the brand at the start, in at least twelve squares; the navigation in the middle, centred on the row whatever the brand and the actions hold; the actions at the end. Where the row is too narrow to centre the links clear of the brand, they stand two squares after it. 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.

Use variant="app" for a simple app title bar: two squares high, one square of horizontal inset, the regular title weight and a bottom hairline. Its title and controls stand on the lower sixteen of the final square, ending on the header’s bottom grid line. It follows the current theme. The title links home; actions and navigation retain the header’s existing responsive behavior.

<ds-header variant="app" brand="Workspace" literal></ds-header>

The matching server-rendered compatibility form is <header class="ds-header ds-header--app"> with a ds-header__brand link. Both forms use the same canonical header.css rules.

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
variantsite or appsiteFull site navigation or compact app title bar.
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.
variantsite or app
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