Skip to content

Hooks

useStepperInput

A hook for coordinating input focus with Stepper keyboard navigation. Use this in custom input components to prevent keyboard conflicts.

tsx
import { useStepperInput } from 'ink-stepper';

const { disableNavigation, enableNavigation, isNavigationDisabled } = useStepperInput();

Returns

NameTypeDescription
disableNavigation() => voidDisables global Stepper navigation (Enter/Escape).
enableNavigation() => voidRe-enables global Stepper navigation.
isNavigationDisabledbooleanCurrent status of navigation.

While navigation is disabled, goNext(), goBack() and goTo() are no-ops as well — not just the Enter/Escape keys. Call enableNavigation() before navigating from a submit handler, otherwise the navigation call is silently dropped. See Input Coordination.

Like useStepperContext (which it calls internally), this hook throws if used outside a <Stepper>.


useStepperContext

A hook to access the internal Stepper context. Useful for building deeply nested components that need to control the wizard.

tsx
import { useStepperContext } from 'ink-stepper';

const { stepContext, currentStepId } = useStepperContext();

stepContext is null when no step is active, so guard before using it. The hook throws if called outside a <Stepper>.

Returns

StepperContextValue.

Released under the MIT License.