ink-cartridge
    Preparing search index...

    Function useFocusState

    • Track whether a focusable element currently holds focus.

      Re-renders whenever focus moves; returns true while focusId is the active focus target (optionally constrained to a focus group).

      Parameters

      Returns boolean

      true when the element currently holds focus.

      Track a TextInput — the same focusId the input registers with the focus system:

      function LoginForm() {
      const focused = useFocusState('username');

      return (
      <Box flexDirection="column">
      <TextInput focusId="username" value={username} onChange={setUsername} />
      <Text dimColor>{focused ? 'editing username' : 'press Tab'}</Text>
      </Box>
      );
      }