Skip to content

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.

FocusRegistryValue | null

Registry value, or null outside a Glyph render tree.

const registry = useFocusRegistry();
if (registry) {
console.log(`${registry.elements.length} focusable elements`);
registry.focusNext();
}

Descriptor for a single focusable element in the registry.

PropertyTypeDescription
idstringUnique focus ID
layoutLayoutRectCurrent layout (position, size)
nodeGlyphNodeThe GlyphNode
typestringNode type (box, input, etc.)

Return type of useFocusRegistry.

PropertyTypeDescription
elementsFocusableElement[]All currently registered focusable elements
focusedIdstring | nullCurrently focused element ID
focusNext() => voidMove to next focusable element
focusPrev() => voidMove to previous focusable element
refresh() => voidManually refresh the element list (useful after layout updates)
requestFocus(id) => voidRequest focus on a specific element