Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit a88ded7

Browse files
docs(c-skip-nav): add details in README
1 parent 34be2dc commit a88ded7

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

packages/c-skip-nav/README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,47 @@ yarn add @chakra-ui/c-skip-nav
1010
npm i @chakra-ui/c-skip-nav
1111
```
1212

13-
## Usage
13+
Per WebAim.org on
14+
[WCAG 2.4.1 (Bypass Blocks - Level A)](https://webaim.org/standards/wcag/checklist#sc2.4.1),
15+
because the main content is not always the first section that the user
16+
encounters on a page, it is strongly recommended to include a skip link for
17+
users to be able to bypass content that is present on multiple pages. Navigation
18+
links are the most common skipped.
19+
20+
> A user with a screen reader or specialized software could skip content via the
21+
> headings or `main` region, but this is not sufficiant enough for sighted users
22+
> who primarily use a keyboard.
23+
24+
## Imports
1425

1526
```sh
1627
import { CSkipNavLink, CSkipNavContent } from '@chakra-ui/c-skip-nav'
1728
```
29+
30+
## Usage
31+
32+
The `CSkipNavLink` component ideally needs to be one of the first items a user
33+
encounters when they begin navigating a page after load. Therefore, it is
34+
recommended to place it as high as possible in the app.
35+
36+
It renders an `a` tag and automatically creates a link with an `href` attribute
37+
that will point to `CSkipNavContent`.
38+
39+
The `CSkipNavContent` component is used as a target for the link to place
40+
keyboard focus on the first piece on main content. It renders a `div` and can
41+
either be a self-closing component, or wrap the main content. (Visually, it
42+
might be better to just wrap the main content so the visual focus outline is
43+
very clear)
44+
45+
> You can supply a custom id value using the `id` prop but you will have to declare
46+
> this prop and value in both components, or they will not match. For Example:
47+
> `id="custom-id"` renders `href="#custom-id"` in `CSkipNavLink` and
48+
> `id="custom-id"` in `CSkipNavContent`.
49+
50+
```tsx
51+
<template>
52+
<c-skip-nav-link>Skip Navigation</c-skip-nav-link>
53+
// * Later in the page after the navigation...
54+
<c-skip-nav-content /> // Or it wraps the main content // Main content below
55+
</template>
56+
```

0 commit comments

Comments
 (0)