useFocusRegistry
function useFocusRegistry(): FocusRegistryValue | null;Access all registered focusable elements and navigation helpers.
Useful for building custom navigation UIs, accessibility overlays, or debug tools. Respects the current FocusScope trap.
Returns
Section titled “Returns”FocusRegistryValue | null
Registry value, or null outside a Glyph render tree.
Example
Section titled “Example”const registry = useFocusRegistry();if (registry) { console.log(`${registry.elements.length} focusable elements`); registry.focusNext();}FocusableElement
Section titled “FocusableElement”Descriptor for a single focusable element in the registry.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
id | string | Unique focus ID |
layout | LayoutRect | Current layout (position, size) |
node | GlyphNode | The GlyphNode |
type | string | Node type (box, input, etc.) |
FocusRegistryValue
Section titled “FocusRegistryValue”Return type of useFocusRegistry.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
elements | FocusableElement[] | All currently registered focusable elements |
focusedId | string | null | Currently focused element ID |
focusNext | () => void | Move to next focusable element |
focusPrev | () => void | Move to previous focusable element |
refresh | () => void | Manually refresh the element list (useful after layout updates) |
requestFocus | (id) => void | Request focus on a specific element |