keyboard focus
The single element on the page that currently receives keyboard input, such as the text box you are typing into.
In more detail
Users move focus with the Tab key and code moves it with element.focus(). Good interfaces move focus predictably, trap it inside open dialogs and return it to the triggering button when a dialog closes.
Example
inputRef.current?.focus() focuses an input from a React event handler.Related terms
- focus trap — Code that keeps keyboard focus inside a container, such as an open modal, wrapping from the last element back to the first.
- tabindex — The HTML attribute that controls whether an element can be focused and whether it is in the tab order.
- keyboard navigation — Using a page entirely with the keyboard: Tab to move between controls, Enter and Space to activate, arrow keys inside widgets, Escape to close.
- ref — A React handle that points at a real DOM element, so code can focus it, measure it or attach listeners.
Taught in
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- useImperativeHandle: Controlled Ref Forwarding Boundaries — React 19 & Modern Component Architecture
- Custom Hook Composition: Encapsulating Reactive Logic — React 19 & Modern Component Architecture
- Virtualization: Rendering Infinite Datasets Efficiently — React 19 & Modern Component Architecture
- Accessible Headless Primitives: ARIA, Focus, And Keyboard — React 19 & Modern Component Architecture