Skip Nav

A link, hidden until focused, that lets keyboard users jump past the navigation to the main content.

Skip to content

Navigation

This stands in for a navigation area that people may want to skip.

Main content

This is the main content. Press Tab, then press Enter on the "Skip to content" link, and focus jumps straight here, past the navigation.

Usage

WebAIM.org on WCAG 2.4.1 (Bypass Blocks - Level A) strongly recommends a skip link past content that repeats on many pages.

Headings and the main region let screen reader users skip content. That is not enough for sighted keyboard users.

Code
import { SkipNavContent, SkipNavLink } from '@leverui/components';
Code
<SkipNavLink>Skip to content</SkipNavLink>
<SkipNavContent />

Examples

Basic Usage

The SkipNavLink component ideally needs to be one of the first items a user encounters when they begin navigating a page after load. Therefore, it is recommended to place it as high as possible in the app.

It renders an a tag and automatically creates a link with an href attribute that will point to SkipNavContent.

The SkipNavContent component is used as a target for the link to place keyboard focus on the first piece of main content. It renders a div and can either be a self-closing component, or wrap the main content.

Skip to content

Navigation

This stands in for a navigation area that people may want to skip.

Main content

This is the main content. Press Tab, then press Enter on the "Skip to content" link, and focus jumps straight here, past the navigation.

Custom ID

You can supply a custom id value using the id prop but you will have to use this prop and value in both components, or they will not match.

Skip to main content

Header and navigation

Both parts in this example use the custom id "main-target" so that they match.

Main content (custom id)

SkipNavLink and SkipNavContent share the id "main-target". That is how the link finds its target and moves focus to it.

With Main Content

The SkipNavContent component can wrap your main content area to ensure proper focus management.

Skip to content

Site header

• Home

• About

• Services

• Contact

Welcome to our site

This is the main content. SkipNavContent wraps this whole section, so the skip link moves focus here.

When someone using a keyboard presses Tab to reach the "Skip to content" link and then presses Enter, focus jumps straight to this section, past all the navigation items above.

This helps people who use a screen reader and people who get around mostly with a keyboard.

In Action

  1. Select Preview on the Basic Usage example.
  2. Press Tab twice. The link appears in the upper left of the window.
  3. Press Enter to move focus to the main content panel.

Guides

SkipNavContent marks where SkipNavLink jumps to. The link is hidden until it has focus. Finish the stylesheet setup first.

Both parts use leverui-skip-nav as the target id by default. For another target, give both parts the same id. On SkipNavLink, id sets the fragment in the href. SkipNavContent has tabIndex={-1}: code can focus it, Tab skips it. Keep the link near the start of the document. Give the target the right meaning for the page, for example with as="main".

In your own layout, check that keyboard focus reaches the target after someone follows the link.

In a Solid Router app, set rel="external" on SkipNavLink. Otherwise the router handles the hash link and the browser does not move focus.

Customize with CSS

.leverui-skip-nav styles the link and .leverui-skip-nav-content its target. --leverui-colors-bg-panel sets the background of the focused link. unstyled on the link turns off its default styles.

For one-off changes, use class or style. Neither part supports object CSS, general style props, or custom recipes.