Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

How can I implement keyboard navigation for a tabbed interface?

Quick answer

For a genuine tabs widget, choose automatic activation (focusing a tab activates it) or manual activation (Space or Enter activates it). Tab enters at the active tab and then leaves the tablist; arrow keys move among tabs and wrap. Use Left/Right for a horizontal tablist or Up/Down for a vertical one. Check whether a panel without focusable content needs tabindex="0". [S1]

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I have a row of labels above changing content. What should I decide before adding keyboard support?

Geez

First decide whether these controls are genuinely tabs: one active tab displays its associated panel, and the controls and panels form a tabs widget. Visual styling alone does not make something a tabs widget. The WAI-ARIA Authoring Practices Guide (APG) describes a tablist, tabs, and associated tabpanels. [S1]

Then choose an activation model. With automatic activation, moving focus to a tab activates it. With manual activation, focus can move among tabs without changing the panel; Space or Enter activates the focused tab. [S1]

For example, with “Overview,” “Details,” and “History,” write down which tab is initially active and which panel belongs to each. Those names are placeholders: the key is to keep focus, selection, and displayed content understandable and coordinated.

Follow-up question

How should focus move through the tabs, and how does someone get to the panel?

Geez

In the APG tabs pattern, Tab enters the tablist at the active tab and then leaves it for the next target in the page sequence. Arrow keys move between tabs and wrap at either end: use Left and Right for a horizontal tablist, or Up and Down for a vertical one. [S1]

For the selected tab’s panel, check whether its content already provides a useful keyboard focus target. A panel that otherwise lacks focusable content may need tabindex="0" so keyboard users can reach it. This is a check, not a requirement to add the attribute to every panel. [S1]

In your design notes, record what should receive focus after leaving the tablist and whether each panel needs to be reachable directly. Then verify the actual order in the page context.

Follow-up question

How do I choose between automatic and manual activation, and what should my specification say?

Geez

Choose one model and document it explicitly. Automatic activation means focus selects the tab. Manual activation allows focus to move without changing selection; Space or Enter selects the focused tab. [S1]

A concise specification could be:

  1. Orientation: horizontal or vertical.
  2. Entry and exit: Tab enters at the active tab and leaves the tablist.
  3. Movement: the orientation’s arrow keys move between tabs and wrap at both ends.
  4. Activation: automatic, or manual with Space/Enter.
  5. Panel access: identify each tab’s panel and check whether the panel needs a focus target.

The bracketed choices are yours to make. Don’t infer the activation model from appearance or leave it undocumented.

Follow-up question

What is a focused test plan that will catch the main keyboard problems?

Geez

Test with the keyboard and record the expected and actual focus location, selected tab, and displayed panel. Include the first and last tabs to check wrapping.

A compact sequence:

  1. Press Tab to enter the tablist and note which tab receives focus.
  2. Use the chosen arrow keys in both directions, including at each end.
  3. With automatic activation, check whether moving focus updates selection and content. With manual activation, move focus without selecting, then try Space and Enter.
  4. Press Tab to leave the tablist and check the next focus target.
  5. Check whether panel content can be reached when it otherwise has no focusable item.

These checks apply the APG pattern to your implementation; they do not establish that a particular implementation is correct. Repeat the sequence in the actual page context.

A practical checklist

  • Confirm the controls represent a tabs widget, not just tab-like styling.

  • Choose an orientation and matching arrow keys.

  • Specify automatic or manual activation.

  • Check entry, exit, arrow-key movement, and wrapping.

  • Check tab-to-panel relationships and whether panels need a focus target.

  • Record expected versus actual focus, selection, and displayed content during keyboard testing.

A few more useful answers

Should every tab receive focus when someone presses Tab?

In this pattern, Tab enters at the active tab; arrow keys move among tabs, and Tab leaves the tablist. [S1]

Do all tab panels need `tabindex="0"`?

No. A panel that otherwise lacks focusable content may need it so keyboard users can reach the panel. Check each panel rather than applying it automatically. [S1]

Sources

References used for this guide.

  1. [S1] W3C WAI-ARIA APG: Tabs Pattern
    w3.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work