Open Source DOM Component

Sitenav

Website pull-out navigation

by Read Write Tools
Abstract
The rwt-sitenav DOM component is a pull-out website navigation menu, with subtle hamburger button, and default activation of the menu item for the current page.

Motivation

Sometimes you need to provide your website visitors with quick access to a large quantity of pages without cluttering the main reading area of the page.

The rwt-sitenav DOM component does this by keeping the menu off the left-hand side of the page until the user needs it. The menu is activated, sliding over the page content, when the user clicks on the hamburger menu button. Activation may also be initiated through the component's toggleMenu method or through its event interface.

The component has these features:

  • The hamburger menu button is subtly displayed along the left-hand margin, appearing brighter on hover.
  • The first few times that a visitor interacts with your website, the menu button pulses to draw attention to itself.
  • The menu scrolls vertically, accommodating any number of menu items.
  • Menu items may be kept separate from the DOM component, allowing the webmaster to change its contents in a single centralized place. Alternatively, menu items may be slotted directly between the component's opening and closing tags.
  • The menu item corresponding to the current page is highlighted and scrolled into view when the page is first loaded.
  • The menu has an event interface for showing and hiding itself.
  • The menu emits a custom event to close sibling menus and dialog boxes.
  • A keyboard listener is provided to allow a shortcut key to open/close the menu.

In the wild

To see an example of this component in use, visit the BLUEFIDDLE website and press F1 "Menu". To understand what's going on under the hood, use the browser's inspector to view the HTML source code and network activity.

Reference

DOM components logo Documentation READ WRITE HUB
git logo Source code github
DOM components logo Component catalog DOM COMPONENTS
npm logo Package installation npm
Read Write Stack logo Publication venue READ WRITE STACK
Read Write Tools icon

Smart tech

READ WRITE TOOLS

Read Write Hub icon

Distraction-free writing

RWDOC

BLUEPHRASE icon

Rediscover HTML

BLUE PHRASE

Read Write Serve icon

Served with pure HTTP/2

RWSERVE

Open Source DOM Component

🔗 🔎