Skip to content

FocusScope

function FocusScope(__namedParameters): Element;

Confines keyboard focus to a sub-tree.

Wrap a dialog, modal, or drawer with <FocusScope trap> to prevent Tab from escaping. When the scope unmounts, the previously focused element is restored automatically.

ParameterType
__namedParametersFocusScopeProps

Element

<FocusScope trap>
<Box style={{ border: "round", padding: 1 }}>
<Input placeholder="Name" />
<Button label="OK" onPress={close} />
</Box>
</FocusScope>

PropertyTypeDescription
children?ReactNodeChildren that participate in the trapped focus cycle.
trap?booleanWhen true, Tab/Shift+Tab cycling is confined to the children of this scope. Previous focus is restored when the scope unmounts.