screen()

Define a command that renders a React/Ink terminal UI instead of running a handler.

Import from maltty/ui.

ScreenDef

FieldTypeDefaultDescription
namestring--Explicit command name (overrides filename-derived name from autoload)
aliasesreadonly string[]--Alternative names for this screen command
descriptionResolvable<string>--Human-readable description shown in help text
hiddenResolvable<boolean>--When true, hidden from help output
deprecatedResolvable<string | boolean>--Marks the screen command as deprecated
optionsArgsDef--Option (flag) definitions -- Zod schema or yargs-native format
positionalsArgsDef--Positional argument definitions
exitScreenExit'manual'Exit behavior: 'manual' or 'auto'
renderComponentType<TArgs>--React component receiving parsed args as props

ScreenExit

ValueDescription
'manual'Screen stays alive until useApp().exit() or Ctrl-C. Default.
'auto'Runtime calls exit automatically once the component unmounts or render settles.

Context hooks

Available inside screen components. Throw if used outside a screen() render tree.

HookReturnsDescription
useConfig<TConfig>()Readonly<TConfig>Validated CLI config
useMeta()Readonly<Meta>CLI metadata (name, version, command, dirs)
useStore()StoreIn-memory key-value store

Layout components

Re-exported from Ink:

ComponentProps typeDescription
BoxBoxPropsFlexbox layout container
TextTextPropsText rendering with color, bold, italic
NewlineNewlinePropsLine break
Spacer--Flexible spacing
StaticStaticPropsStatic content that is not re-rendered
TransformTransformPropsRender transform wrapper

Input components

Re-exported from @inkjs/ui:

ComponentProps typeDescription
SelectSelectPropsSingle-choice selection list
MultiSelectMultiSelectPropsMulti-choice selection list
TextInputTextInputPropsText input field
PasswordInputPasswordInputPropsMasked text input for secrets
ConfirmInputConfirmInputPropsYes/no confirmation prompt
SpinnerSpinnerPropsAnimated spinner with optional label

Ink hooks

Re-exported from Ink:

HookDescription
useApp()Access app instance (exit(), waitUntilExit())
useInput(handler)Handle keyboard input
useFocus(options)Manage focus state
useFocusManager()Control focus programmatically
useStdin()Access stdin stream
useStdout()Access stdout stream
useStderr()Access stderr stream
useCursor()Show/hide terminal cursor
useIsScreenReaderEnabled()Detect screen reader

MalttyProvider

Wraps screen components automatically. Not typically instantiated directly.

PropTypeDescription
childrenReactNodeReact tree to wrap
valueMalttyContextValueContext containing config, meta, store

Types

Exported from maltty/ui:

TypeDescription
ScreenDefDefinition object passed to screen()
ScreenExit'auto' | 'manual'
ScreenRenderPropsInternal props passed to the render function
MalttyProviderPropsProps for the MalttyProvider component
OptionOption type for Select/MultiSelect

References