Design Autofocus Rules
Accessibility · focus, forms, keyboard
Updated 2026-07-28
- Autofocus only when the field is the entire purpose of the screen. A search page, a login form, or a single-input dialog qualifies. A long page with a newsletter box does not.
- Never autofocus something below the fold. Focusing an off-screen field scrolls the page for the user without being asked and hides whatever they were about to read.
- Be careful with autofocus on mobile. Focusing an input opens the keyboard, which covers half the screen before the user has decided what to do.
- Focus the first thing that needs attention, not just the first thing that exists:
- In a dialog, the primary action or the first field.
- After a failed submit, the first field with an error.
- After adding a row, the new row's first input.
- Move focus when you move the user. If an action replaces the content on screen, focus has to follow, otherwise keyboard users are still parked on a control that no longer exists.
- Never steal focus from someone who is already typing. Late-arriving content, polling, and background saves must not reset the caret.
- Make the focused element obviously focused. Autofocus without a visible focus style just makes keystrokes disappear into an invisible target.
Focus is a pointer for people who do not use a pointer, so treat moving it as a deliberate design decision.
Related guides