0Pricing
Web Accessibility Academy · Урок

Навигация между вкладками стрелками

Позвольте пользователям перемещаться между вкладками с клавиатуры.

«Навигация между вкладками стрелками» — бесплатный урок Web Accessibility Academy на CoddyKit. Это урок 2 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Web Accessibility Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Web Accessibility Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

Tabs Are Not Just Clickable

A correct tab set is driven by the keyboard, not the mouse alone. The APG pattern expects arrow keys to move between tabs.

The Tablist Is One Tab Stop

Pressing Tab should land on the tab set just once, not stop on every tab. The whole tablist behaves as a single stop in the page order.

Only One Tab Is Tabbable

Give the active tab tabindex="0" and every other tab tabindex="-1". This is the roving tabindex that keeps Tab from hitting them all.

<button role="tab" tabindex="0">Profile</button>

Arrow Keys Move Focus

Inside a horizontal tablist, Right and Left arrows move focus from tab to tab. This is how keyboard users explore the set.

Up and Down for Vertical Tabs

If your tabs stack vertically, use Up and Down arrows instead. Set aria-orientation="vertical" so assistive tech knows the layout.

<div role="tablist" aria-orientation="vertical">...</div>

Wrap Around at the Ends

When focus is on the last tab and the user presses the next arrow, wrap back to the first. Looping keeps navigation smooth and predictable.

Home and End Jump Far

Add two shortcuts: Home moves focus to the first tab and End moves it to the last. Long tab sets become much faster to navigate.

Move the Roving Index

When an arrow shifts focus, update the tabindex: set the newly focused tab to 0 and the old one to -1, then call focus on it.

newTab.tabIndex = 0; oldTab.tabIndex = -1; newTab.focus();

Automatic Activation

With automatic activation, focusing a tab also selects it and shows its panel. It feels instant but can be heavy if panels are costly.

Manual Activation

With manual activation, arrows only move focus; the user presses Enter or Space to select. Prefer this when revealing a panel is expensive.

Why This Matters

Without arrow support, keyboard users must Tab through every tab and panel. Proper key handling makes the widget efficient, not just reachable.

Quick Check

Focus is on a tab in a horizontal tablist. The user presses the Right arrow. What should happen?

Recap: Arrow Navigation

You learned tabs use a roving tabindex with arrow keys, plus Home and End. Choose automatic or manual activation based on panel cost.

Часто задаваемые вопросы

Урок «Навигация между вкладками стрелками» бесплатный?

Да — полный текст урока «Навигация между вкладками стрелками» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Web Accessibility Academy, подпишись на CoddyKit PRO. Курс Web Accessibility Academy содержит 4 уроков всего.

Чему я научусь в уроке «Навигация между вкладками стрелками»?

Позвольте пользователям перемещаться между вкладками с клавиатуры. Ты практикуешь Web Accessibility Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Web Accessibility Academy?

Предыдущий опыт не требуется. Web Accessibility Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 2 из 4.

Сколько времени занимает урок «Навигация между вкладками стрелками»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Web Accessibility Academy?

Да. Каждый урок Web Accessibility Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Шаблон вкладок: tablist, tab, tabpanel
  2. Навигация между вкладками стрелками
  3. Аккордеоны с Button и aria-expanded
  4. Раскрывающийся элемент или вкладки: выберите подходящий вариант
← Назад к Web Accessibility Academy