Skip link
Lets keyboard users jump past repeated navigation to the main content.
Example
<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>import { SkipLink } from '@focsd-dev/react';
export function Example() { return <SkipLink href="#main">Skip to main content</SkipLink>;}<script setup>import '@focsd-dev/components/focsd-skip-link.js';</script>
<template> <focsd-skip-link href="#main">Skip to main content</focsd-skip-link></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-skip-link.js';
// template<focsd-skip-link href="#main">Skip to main content</focsd-skip-link><script> import '@focsd-dev/components/focsd-skip-link.js';</script>
<focsd-skip-link href="#main">Skip to main content</focsd-skip-link>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
href | href | string | #main |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
CSS parts
Style the inside of the component with ::part(), for example focsd-skip-link::part(link).
| Part | Description |
|---|---|
link | The 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 firstfocsd-app-shellin 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 pointhrefat it instead.
Keyboard
| Key | Action |
|---|---|
| Tab (first) | Reveal |
| Enter | Jump to the target |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.