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
tabindexattribute (sotabindex="-1"is a valid script-focus target; a plain<div>is not). - Excluded:
disableditself or inside a disabled<fieldset>,hidden/inert/aria-hidden="true"ancestors,display: noneon the element or any ancestor, andvisibility: hidden.
Sequential (Tab) reachability is stricter โ see getFocusableElements, which also drops
negative tabindex.
- Kind: Function
- Source: packages/core/src/focus/focus.ts:52
Signature
function isFocusable(element: HTMLElement): boolean
| Parameter | Type | Optional | Description |
|---|---|---|---|
element |
HTMLElement |
Returns boolean