All skills
sergiodxa avatar

/frontend-accessibility-best-practices

@4d1d816

Accessibility (a11y) best practices for React components. Use when creating UI components, forms, interactive elements, or reviewing code for accessibility compliance.

Use this Skill: https://skilld.dev/gh/sergiodxa/agent-skills/frontend-accessibility-best-practices

This session only. Nothing lands on disk.

rulessemantic-html-landmarks.md

≈659 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Use Semantic HTML Landmarks

Use semantic HTML elements to create page landmarks that screen readers can navigate.

Why

  • Screen reader users can jump between landmarks (main, nav, header, footer)
  • Provides document outline without relying on visual layout
  • Better SEO and machine readability

Landmark Elements

Element Purpose ARIA Role
<main> Primary page content main
<nav> Navigation links navigation
<header> Introductory content banner (when top-level)
<footer> Footer content contentinfo (when top-level)
<aside> Tangentially related content complementary
<section> Thematic grouping region (when labeled)
<article> Self-contained content article

Bad

// Generic divs provide no semantic meaning
function Page() {
  return (
    <div className="page">
      <div className="header">...</div>
      <div className="sidebar">...</div>
      <div className="content">...</div>
      <div className="footer">...</div>
    </div>
  );
}

Good

import { Main } from "~/components/heading";

function Page() {
  return (
    <>
      <header>
        <nav aria-label={t("Primary")}>...</nav>
      </header>

      <Main>
        <article>...</article>
        <aside>...</aside>
      </Main>

      <footer>...</footer>
    </>
  );
}

Multiple Navigation Regions

When you have multiple <nav> elements, label them:

<header>
  <nav aria-label={t("Primary site")}>
    {/* Main navigation */}
  </nav>
</header>

<aside>
  <nav aria-label={t("Table of contents")}>
    {/* Page navigation */}
  </nav>
</aside>

<footer>
  <nav aria-label={t("Footer")}>
    {/* Footer links */}
  </nav>
</footer>

Rules

  1. Every page should have exactly one <main> element (use Main component)
  2. Use <header> for page/section headers, not just <div className="header">
  3. Use <nav> for navigation, always with aria-label when multiple exist
  4. Use <footer> for page/section footers
  5. Use <article> for self-contained content (blog posts, cards, comments)
  6. Use <aside> for sidebars, related content, or call-outs
  7. Use <section> with Region component for labeled content sections

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive set of accessibility (a11y) guidelines and code examples for building inclusive React applications. It covers semantic HTML, screen reader support, keyboard navigation, and user preferences without including any executable scripts or network-connected components. No security risks or malicious patterns were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    5/8 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 4d1d816. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for sergiodxa/agent-skills/frontend-accessibility-best-practices