Start with the interaction model
This exercise uses automatic activation because all panel content is already available. Moving focus to another tab immediately selects it. For panels that require a slow request, discuss manual activation with Enter or Space instead.
Store one selection
Keep an index in state and derive the visible panel from it. Validate defaultActiveIndex once when initializing state; a negative, fractional, or out-of-range value falls back to zero. The default is an initial value, not a controlled prop.
Move focus as well as selection
ArrowRight uses (index + 1) % length; ArrowLeft uses (index - 1 + length) % length. Home and End choose the boundaries. Prevent the default only for those handled keys, update selection, and focus the matching button using refs. Tab remains native.
Keep relationships valid
A useId prefix separates component instances. Each tab controls an existing panel; each panel is labelled by its tab. Render all panels with hidden on inactive ones, which preserves their local state and removes them from normal focus and accessibility navigation. Rendering only the active panel is another valid design, but unmounts its state.
Make focus visible
Exactly one tab has tabIndex=0. The text panel is also focusable. Keep a visible focus outline on both. Styling aria-selected is valid and keeps the visual selection tied to the semantic state.
Walk through it
Focus HTML, press Left to reach React, then Home to return to HTML. Tab enters the HTML panel. Render a second Tabs instance with the same item IDs and verify its DOM IDs differ. Test empty input and defaultActiveIndex=99.