Skip to content

autoFocusProps

Reports autoFocus props that are not set to false.

✅ This rule is included in the jsx logical preset.

Auto-focusing elements automatically grab the user’s focus, which is generally disruptive behavior. It can be particularly disruptive to users who rely on screen readers and/or keyboard navigation.

Consider letting users focus elements manually instead.

<button autoFocus />
<button autoFocus="true" />
<input autoFocus={true} />

If you have specific use cases where auto-focus is necessary for user experience (such as modal dialogs), you may want to disable this rule for those specific cases. Auto-focusing elements should only sparingly be used when explicitly triggered by users.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.