Skip to content

useKeyboardHint

@astryxdesign/core v0.7.1 · useKeyboardHint

Parameters ​

NameTypeDefaultDescription
optionsUseKeyboardHintOptions{}Configuration object for the keyboard hint. Optional.
options.orientation'horizontal' | 'vertical' | 'both''horizontal'Which arrow-key axis the composite navigates, controlling which arrow icons the hint shows (← → for horizontal, ↑ ↓ for vertical, all four for both).
options.dismissAfterMsnumber3000Milliseconds before the hint auto-dismisses after appearing.
options.isEnabledbooleantrueWhether the hint is enabled. Set to false to suppress it for a specific instance (e.g. a disabled or read-only widget).

Returns ​

NameTypeDescription
HintComponentThe hint element to render inside the composite container as the last child, e.g. <component :is="hint.Hint" />. It positions itself fixed, renders arrow keys with Kbd, and manages its own visibility. Render it unconditionally.
visibleRef<boolean>Whether the hint is currently shown. Hint reads it; a custom hint element can too.
anchorRef<HTMLElement | null>The focused item the hint is anchored to. null before the first show.
orientationComputedRef<KeyboardHintOrientation>The resolved orientation, with the default applied.
onFocus(event: FocusEvent) => voidBind to the container's focusin (@focusin), because focus does not bubble. Shows the hint on the first keyboard-focus (:focus-visible) entry from outside the composite.
onBlur(event: FocusEvent) => voidBind to the container's focusout (@focusout). Hides the hint when focus leaves the composite entirely and counts that as a dismissal, so it does not come back for this instance; focus moves within the composite only re-anchor it.
onKeyDown(event: KeyboardEvent) => voidBind to the container's keydown. Dismisses the hint on the first arrow press (the user has discovered the interaction). Never prevents default or stops propagation.