import { Canvas, Meta, Story } from "@storybook/addon-docs/blocks";
import * as Stories from "./skipLinks.stories.js";

<Meta of={Stories} />

# Skip Links

Skip links can help users quickly move past blocks of content they do not want to navigate through. The most important instance of them is a skip navigation link. This is a link at the start of a page that allows keyboard users to move straight to the main content on a page allowing them to bypass the common content at the start of the pages.

## Requirements

Skip Links should be the first element on the page, so that they recieve focus as soon as the user starts tabbing.

Each skip link's `href` attribute must reference an `id` of an element on the page. Default browser behaviour will then navigate to the element. The target itself must be focusable to continue tabbing within, which can be achieved by setting a `tabindex="-1"` on a div.

```html
<nav class="qld-skip-links" aria-label="skip to content links">
  <a class="qld-skip-links__item" href="#content">Skip to main content</a>
</nav>

...content...

<main id="content" tabindex="-1">Main content</main>
```

<Canvas of={Stories.Default} />

## See also

- [Skip Navigation Links (WebAIM)](https://webaim.org/techniques/skipnav/)
- [Skip Link Easy Check (W3C)](https://www.w3.org/WAI/test-evaluate/easy-checks/skip-link/)
