NavBar
A horizontal navigation bar with a brand at the start, items, and actions. Below the breakpoint, it collapses behind a hamburger button. Items are links with an active state.
Navigation · TaishoDS Core, in plain HTML.
Examples
One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.
Navigation bar with responsive menu
When to use
- There are only a few main sections, and they fit on one line.
- You want the brand, navigation, and account actions in one place.
- The content benefits from the full width below it.
When not to use
- There are many sections and subsections (docs, a dashboard) →
sidebar. - It’s navigation within a single page →
tocortabs.
Do
- Few items, always the same ones. The bar is the site’s stable map.
- Mark the active item so users know where they are.
Don’t
- Don’t put a dashboard’s entire navigation in it. It won’t fit, and it breaks on mobile.
- Don’t make it sticky (
is-sticky) if it covers content on short screens.
Related
TaishoDS Core
Needs Core’s JS, which hooks in through data-ts-* attributes.
Switches between the full bar and the compact menu based on width, and opens and closes that menu.
Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.
data-ts-toggledata-ts-toggle-escapedata-ts-toggle-outsidedata-ts-toggle-rootdata-ts-toggle-target
What it does: Opens and closes the mobile menu. The responsive breakpoint can be handled with a container query, without JavaScript. Esc closes the menu (data-ts-toggle-escape) and returns focus to the button if focus was inside. A pointer press outside the bar (data-ts-toggle-root) also closes it (data-ts-toggle-outside).
From the CDN, without a build, load taisho.nav-bar.css along with taisho.base.css. Also load:
taisho.button.csstaisho.icon.csstaisho.kbd.csstaisho.spinner.css
For how Core works in general, see Behavior.
Accessibility
- It’s a
<nav>with an accessible name. On mobile, the menu button exposesaria-expanded. - With the mobile menu open, a pointer press outside the bar closes it without moving focus. A press inside the bar doesn’t close it.
Keyboard
On top of what the browser already does (Tab moves focus, Enter activates a button).
| Key | What it does |
|---|---|
| Esc | With the mobile menu open, closes it. If focus was inside the menu, it returns to the menu button. |
Verification
What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.
- axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
- keyboard Key map documented above, checked against the component.
- screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.