Search documentation

Type to search the documentation.

API: Core

isFocusable

Whether element can receive programmatic focus (element.focus()) right now.

Overview

Whether element can receive programmatic focus (element.focus()) right now.

  • Must be connected, and match the focusable selector or carry a tabindex attribute (so tabindex="-1" is a valid script-focus target; a plain <div> is not).
  • Excluded: disabled itself or inside a disabled <fieldset>, hidden/inert/ aria-hidden="true" ancestors, display: none on the element or any ancestor, and visibility: hidden.

Sequential (Tab) reachability is stricter โ€” see getFocusableElements, which also drops negative tabindex.

Signature

function isFocusable(element: HTMLElement): boolean
Parameter Type Optional Description
element HTMLElement

Returns boolean