Skip to content

a11y: Add skip to main content link for keyboard navigation#8365

Open
MorikawaSouma wants to merge 1 commit intoreactjs:mainfrom
MorikawaSouma:fix/add-skip-navigation-link-8360
Open

a11y: Add skip to main content link for keyboard navigation#8365
MorikawaSouma wants to merge 1 commit intoreactjs:mainfrom
MorikawaSouma:fix/add-skip-navigation-link-8360

Conversation

@MorikawaSouma
Copy link

Summary

This PR adds a "Skip to main content" link to improve keyboard navigation accessibility on react.dev.

Changes

  • Added a visually hidden skip link at the top of the page that becomes visible when focused
  • Added id="main-content" to the main content area for the skip link target
  • Used Tailwind's sr-only and focus: utilities for the implementation

Accessibility Impact

This addresses WCAG 2.4.1 (Level A) - Bypass Blocks:

A mechanism is available to bypass blocks of content that are repeated on multiple Web pages.

Keyboard-only users previously had to tab through the entire navigation on every page load before reaching the main content. This is especially impactful on a documentation site where users navigate between many pages.

Testing

  1. Navigate to any page on the site
  2. Press Tab key - the "Skip to main content" link should appear
  3. Press Enter - focus should jump to the main content area

Related Issue

Related to #8360

Screenshot

When focused, the skip link appears in the top-left corner of the page.

This adds a skip navigation link that allows keyboard users to bypass
the navigation and jump directly to the main content. The link is
visually hidden by default but becomes visible when focused.

This addresses WCAG 2.4.1 (Level A) - Bypass Blocks.

Related to reactjs#8360
@github-actions
Copy link

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 115.31 KB (🟡 +180 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 127.12 KB (🟡 +109 B) 242.43 KB
/500 127.13 KB (🟡 +109 B) 242.44 KB
/[[...markdownPath]] 129.57 KB (🟡 +109 B) 244.88 KB
/errors 127.37 KB (🟡 +109 B) 242.69 KB
/errors/[errorCode] 127.35 KB (🟡 +109 B) 242.66 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant