Skip to content
Content Blocks docsv0.8.0Website

Docs / Components

<content-navigation-block>

Site navigation that collapses into a menu button on the breakpoints you choose, with a skip link for keyboard users.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-navigation-block';

Examples

A site menu

A row of links from 768px, and a menu button that opens them over the page on phones.

Open on its own

Anatomy

Content goes into the component's slots, chosen with the slot attribute on each child.

flowchart LR
  root["#lt;content-navigation-block#gt;"]:::component
  root --> s0["<b>no slot (default)</b><br/>The default slot"]
  root --> s1["<b>slot=#quot;closeButton#quot;</b><br/>This slot will close the navigation when clicked."]
  root --> s2["<b>slot=#quot;content#quot;</b><br/>Default slot"]
  root --> s3["<b>slot=#quot;openButton#quot;</b><br/>This slot will expand the navigation when clicked."]
  root --> s4["<b>slot=#quot;skipContent#quot;</b><br/>This slot is a keyboard-focus link that lets a screen-reader or keybo…"]
  classDef component fill:#141413,color:#faf9f5,stroke:#141413
The slots of <content-navigation-block>
SlotWhat goes in it
(default)The default slot
slot="closeButton"This slot will close the navigation when clicked.
slot="content"Default slot
slot="openButton"This slot will expand the navigation when clicked.
slot="skipContent"This slot is a keyboard-focus link that lets a screen-reader or keyboard user skip the navigation block and scroll to the end.

Properties

Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.

AttributeTypeDefaultDescription
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
close-labelString'Close menu'The accessible name of the default close button.
hamburgerresponsiveSelect

fixed · absolute · sticky · static · none

'fixed|none'Not documented yet
open-labelString'Open menu'The accessible name of the default menu button.
paddingresponsiveString–Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
flowchart LR
  v["hamburger=#quot;fixed|none#quot;"]:::value
  v --> b0["mobile, from 0px: fixed"]
  v --> b1["tablet and up, from 768px: none"]
  classDef value fill:#1d4ed8,color:#fff,stroke:#1d4ed8
How hamburger="fixed|none" from the examples applies at each breakpoint