Communitygithub.com

WebアクセシビリティとWCAG

WCAG 2.2 コンプライアンスのためのWebアクセシビリティパターン集。ARIA、キーボードナビゲーション、スクリーンリーダー対応、テスト手法を網羅しています。

WebアクセシビリティとWCAG とは?

このスキルは、WCAG 2.2 ガイドラインに準拠したWebアクセシビリティ実装のベストプラクティスを提供します。セマンティックHTMLの使用法、ARIA(Accessible Rich Internet Applications)パターン、キーボードナビゲーション、フォームのアクセシビリティ、カラーコントラストの確保など、フロントエンド開発者が日常的に直面するアクセシビリティ課題を解決するための実践的なコード例が含まれています。React/TSXを使用したモーダルダイアログ、タブコンポーネント、フォームの実装例を示し、キーボード操作(Tab、Enter、Escape、矢印キー)のハンドリング方法も解説。また、よくあるアンチパターン(色のみでの情報伝達、フォーカスアウトラインの削除など)を指摘し、それを避けるための具体的な代替手法を提供します。最終的なチェックリストにより、プロジェクトのアクセシビリティ品質を評価できます。このスキルはClaude Code、Cursor、Codexなど、あらゆるAIエージェントプラットフォームで活用可能です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/accessibility-wcag

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

アクセシビリティとWCAG

セマンティックHTML

<!-- 汎用のdivではなく、セマンティック要素を使用 -->
<header>
  <nav aria-label="メインナビゲーション">
    <ul>
      <li><a href="/" aria-current="page">ホーム</a></li>
      <li><a href="/products">製品</a></li>
      <li><a href="/about">会社概要</a></li>
    </ul>
  </nav>
</header>

<main>
  <article>
    <h1>製品詳細</h1>
    <section aria-labelledby="specs-heading">
      <h2 id="specs-heading">仕様</h2>
      <dl>
        <dt>重量</dt>
        <dd>1.2 kg</dd>
        <dt>寸法</dt>
        <dd>30 x 20 x 10 cm</dd>
      </dl>
    </section>
  </article>
</main>

<footer>
  <p>&copy; 2024 会社名</p>
</footer>

ランドマークとして<div>の代わりに<nav>、<main>、<article>、<section>、<aside>を使用します。スクリーンリーダーはこれらを使ってページ内を移動します。

ARIAパターン

function Modal({ isOpen, onClose, title, children }) {
  if (!isOpen) return null;

  return (
    <div
      role="dialog"
      aria-modal="true"
      aria-labelledby="modal-title"
      onKeyDown={(e) => e.key === "Escape" && onClose()}
    >
      <h2 id="modal-title">{title}</h2>
      <div>{children}</div>
      <button onClick={onClose} aria-label="ダイアログを閉じる">
        <XIcon aria-hidden="true" />
      </button>
    </div>
  );
}

function Tabs({ tabs, activeIndex, onChange }) {
  return (
    <div>
      <div role="tablist" aria-label="設定セクション">
        {tabs.map((tab, i) => (
          <button
            key={tab.id}
            role="tab"
            id={`tab-${tab.id}`}
            aria-selected={i === activeIndex}
            aria-controls={`panel-${tab.id}`}
            tabIndex={i === activeIndex ? 0 : -1}
            onClick={() => onChange(i)}
            onKeyDown={(e) => handleArrowKeys(e, i, tabs.length, onChange)}
          >
            {tab.label}
          </button>
        ))}
      </div>
      {tabs.map((tab, i) => (
        <div
          key={tab.id}
          role="tabpanel"
          id={`panel-${tab.id}`}
          aria-labelledby={`tab-${tab.id}`}
          hidden={i !== activeIndex}
          tabIndex={0}
        >
          {tab.content}
        </div>
      ))}
    </div>
  );
}

キーボードナビゲーション

function handleArrowKeys(
  event: React.KeyboardEvent,
  currentIndex: number,
  totalItems: number,
  onSelect: (index: number) => void
) {
  let newIndex = currentIndex;

  switch (event.key) {
    case "ArrowRight":
    case "ArrowDown":
      newIndex = (currentIndex + 1) % totalItems;
      break;
    case "ArrowLeft":
    case "ArrowUp":
      newIndex = (currentIndex - 1 + totalItems) % totalItems;
      break;
    case "Home":
      newIndex = 0;
      break;
    case "End":
      newIndex = totalItems - 1;
      break;
    default:
      return;
  }

  event.preventDefault();
  onSelect(newIndex);
}

すべてのインタラクティブ要素はキーボードで到達可能である必要があります。Tabキーでフォーカス移動、Enter/Spaceキーでアクティブ化、矢印キーでコンポーネント内の移動を行います。

フォームのアクセシビリティ

function SignupForm() {
  return (
    <form aria-labelledby="form-title" noValidate>
      <h2 id="form-title">アカウント作成</h2>

      <div>
        <label htmlFor="email">メールアドレス</label>
        <input
          id="email"
          type="email"
          required
          aria-required="true"
          aria-describedby="email-hint email-error"
          aria-invalid={hasError ? "true" : undefined}
        />
        <p id="email-hint">あなたのメールアドレスを共有することはありません。</p>
        {hasError && (
          <p id="email-error" role="alert">
            有効なメールアドレスを入力してください。
          </p>
        )}
      </div>

      <button type="submit">アカウント作成</button>
    </form>
  );
}

色とコントラスト

:root {
  --text-primary: #1a1a1a;      /* 白地で15.3:1 */
  --text-secondary: #595959;    /* 白地で7.0:1 */
  --text-on-primary: #ffffff;   /* ブランドカラー上で4.5:1以上を確保 */
  --border-focus: #0066cc;      /* 可視フォーカスリング */
}

*:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

.error-message {
  color: #d32f2f;
  /* 色だけに頼らない - アイコンやテキスト接頭辞を追加 */
}
.error-message::before {
  content: "エラー: ";
  font-weight: bold;
}

WCAG AAでは、通常テキストで4.5:1、大きいテキスト(18px太字または24px標準)で3:1のコントラスト比が必要です。

アンチパターン

  • クリック可能な要素にbuttonやaの代わりにdivやspanを使用する
  • フォーカスアウトラインを削除し、代替指標を提供しない
  • 情報を伝えるために色だけに頼る(赤=エラー、緑=成功)
  • 要素をラベル付けする可視テキストが存在する場合にaria-labelを使用する
  • 一時停止機能なしでメディアを自動再生する
  • キーボードユーザー向けのスキップナビゲーションリンクがない

チェックリスト

  • すべてのインタラクティブ要素がキーボードでアクセス可能(Tab、Enter、Escape、矢印キー)
  • セマンティックHTMLランドマークを使用(nav、main、article、section)
  • 画像に説明文のaltテキストがある(装飾画像はalt="")
  • 色のコントラストがWCAG AAを満たしている(通常テキスト4.5:1、大きいテキスト3:1)
  • すべてのインタラクティブ要素にフォーカスインジケータが表示される
  • フォーム入力に<label>要素が関連付けられている
  • エラーメッセージがrole="alert"でスクリーンリーダーに通知される
  • スクリーンリーダー(VoiceOver、NVDA)とキーボードのみでページをテスト済み

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Create forensically sound bit-for-bit disk images using dd and dcfldd while preserving evidence integrity through hash verification.

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

関連スキル