Skip to content
Focsd homeFocsd homeFocsd
Forms

Skip link

Lets keyboard users jump past repeated navigation to the main content.

  • Tag: focsd-skip-link
  • Pattern: Skip link
  • Category: Navigation

Example

HTML
<focsd-skip-link href="#main">Skip to main content</focsd-skip-link>
<p>Press Tab to reveal the skip link.</p>
<main id="main" tabindex="-1"><p>Main content</p></main>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-skip-link.js';
</script>
<focsd-skip-link href="#main">Skip to main content</focsd-skip-link>

API

Attributes

AttributePropertyTypeDefault
hrefhrefstring#main

Slots

SlotDescription
(default)Default content.

CSS parts

Style the inside of the component with ::part(), for example focsd-skip-link::part(link).

PartDescription
linkThe link element.

Accessibility

  • Hidden until focused, then shown in the top start corner above everything else. Make it the first element in <body>.
  • Activating it moves focus to the target, adding tabindex="-1" when the target has none.
  • With the default href="#main" and no element with that id, it focuses the main landmark of the first focsd-app-shell in the document. A shell inside another component's shadow root is not found, and with two shells the first wins; give your main an id and point href at it instead.

Keyboard

KeyAction
Tab (first)Reveal
EnterJump to the target