pages.keyboardNavigation.shortcuts.title

Tab
pages.keyboardNavigation.shortcuts.tab
Shift + Tab
pages.keyboardNavigation.shortcuts.shiftTab
Entrée / Espace
pages.keyboardNavigation.shortcuts.enter
Échap
pages.keyboardNavigation.shortcuts.escape
↑ ↓
pages.keyboardNavigation.shortcuts.arrows

pages.keyboardNavigation.listNavigation.title

components.exampleToggle.badExample

pages.keyboardNavigation.listNavigation.bad.intro

<!-- pages.keyboardNavigation.codeExamples.listNavigation.badComment -->
<div class="menu">
  <div tabindex="0">🏠 pages.keyboardNavigation.codeExamples.listNavigation.home</div>
  <div tabindex="0">📋 pages.keyboardNavigation.codeExamples.listNavigation.projects</div>
  <div tabindex="0">👥 pages.keyboardNavigation.codeExamples.listNavigation.team</div>
  <div tabindex="0">📊 pages.keyboardNavigation.codeExamples.listNavigation.stats</div>
  <div tabindex="0">⚙️ pages.keyboardNavigation.codeExamples.listNavigation.settings</div>
</div>

<!-- pages.keyboardNavigation.codeExamples.listNavigation.userMustTab5Times -->
<!-- pages.keyboardNavigation.codeExamples.listNavigation.noArrowNavigation -->
<!-- pages.keyboardNavigation.codeExamples.listNavigation.noMenuSemantics -->

components.exampleToggle.goodExample

pages.keyboardNavigation.listNavigation.good.intro

💡 pages.keyboardNavigation.listNavigation.good.hint

<!-- pages.keyboardNavigation.codeExamples.listNavigation.goodComment -->
<div
  role="menu"
  @keydown="handleKeydown"
>
  <div
    v-for="(item, i) in items"
    role="menuitem"
    :tabindex="selected === i ? 0 : -1"
    @focus="selected = i"
    :class="{ selected: selected === i }"
  >
    {{ item }}
  </div>
</div>
// pages.keyboardNavigation.codeExamples.listNavigation.arrowNavigationComment
function handleKeydown(e) {
  switch(e.key) {
    case 'ArrowDown':
      selected = (selected + 1) % items.length
      break
    case 'ArrowUp':
      selected = selected === 0
        ? items.length - 1
        : selected - 1
      break
    case 'Enter':
      selectItem(selected)
      break
  }
}

components.exampleToggle.explanation pages.keyboardNavigation.listNavigation.explanation

pages.keyboardNavigation.focusStyles.title

components.exampleToggle.badExample

pages.keyboardNavigation.focusStyles.intro

pages.keyboardNavigation.focusStyles.link
/* ❌ pages.keyboardNavigation.codeExamples.focusIndicators.removeFocusComment */
*:focus {
  outline: none !important;
}

button:focus,
a:focus,
input:focus {
  outline: none !important;
}
<!-- pages.keyboardNavigation.codeExamples.focusIndicators.accessibilityProblems -->
<button>pages.keyboardNavigation.codeExamples.focusIndicators.button1</button>        <!-- pages.keyboardNavigation.codeExamples.focusIndicators.button1NoType -->
<button>pages.keyboardNavigation.codeExamples.focusIndicators.button2</button>        <!-- pages.keyboardNavigation.codeExamples.focusIndicators.button2NoType -->
<a href="#">pages.keyboardNavigation.codeExamples.focusIndicators.link</a>           <!-- pages.keyboardNavigation.codeExamples.focusIndicators.linkNoFocus -->
<input type="text" />         <!-- pages.keyboardNavigation.codeExamples.focusIndicators.inputNoFocus -->

<!-- pages.keyboardNavigation.codeExamples.focusIndicators.keyboardNavigationNotVisible -->

components.exampleToggle.goodExample

pages.keyboardNavigation.focusStyles.intro

pages.keyboardNavigation.focusStyles.link
/* ✅ pages.keyboardNavigation.codeExamples.focusIndicators.visibleFocusComment */
button:focus-visible {
  outline: 3px solid #4F46E5;
  outline-offset: 2px;
}

input:focus-visible {
  border-color: #4F46E5;
  outline: 2px solid #4F46E5;
  outline-offset: 1px;
}
<button type="button">pages.keyboardNavigation.codeExamples.focusIndicators.button1</button>
<button type="button">pages.keyboardNavigation.codeExamples.focusIndicators.button2</button>
<a href="#">pages.keyboardNavigation.focusStyles.link</a>
<input type="text" placeholder="pages.keyboardNavigation.focusStyles.input" />

components.exampleToggle.explanation pages.keyboardNavigation.focusStyles.explanation

pages.keyboardNavigation.skipLink.title

components.exampleToggle.badExample

<!-- pages.keyboardNavigation.codeExamples.skipLinks.badComment -->
<header>
  <nav>
    <a href="#">pages.keyboardNavigation.codeExamples.skipLinks.home</a>
    <a href="#">pages.keyboardNavigation.codeExamples.skipLinks.products</a>
    <a href="#">pages.keyboardNavigation.codeExamples.skipLinks.services</a>
    <!-- pages.keyboardNavigation.codeExamples.skipLinks.tenPlusLinks -->
  </nav>
</header>
<main>
  <!-- pages.keyboardNavigation.codeExamples.skipLinks.userMustTraverse -->
  <h1>pages.keyboardNavigation.codeExamples.skipLinks.mainContent</h1>
</main>

components.exampleToggle.goodExample

/* pages.keyboardNavigation.codeExamples.skipLinks.skipLinkComment */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: 0.625rem;
}

.skip-link:focus {
  top: 1rem;
}
<a href="#main-content" class="skip-link">
  pages.keyboardNavigation.codeExamples.skipLinks.skipToContent
</a>
<header>
  <nav aria-label="navigation.ariaLabel">
    <ul>
      <li><a href="/">pages.keyboardNavigation.codeExamples.skipLinks.home</a></li>
      <li><a href="/produits">pages.keyboardNavigation.codeExamples.skipLinks.products</a></li>
      <li><a href="/services">pages.keyboardNavigation.codeExamples.skipLinks.services</a></li>
    </ul>
  </nav>
</header>
<main id="main-content">
  <h1>pages.keyboardNavigation.codeExamples.skipLinks.mainContent</h1>
</main>

components.exampleToggle.explanation pages.keyboardNavigation.skipLink.explanation

pages.keyboardNavigation.modalTrap.title

components.exampleToggle.badExample

components.exampleToggle.goodExample

components.exampleToggle.explanation pages.keyboardNavigation.modalTrap.explanation