Skip to main content
Version: 0.17.1

TUI Components Overview

Invowk™ includes a set of interactive terminal UI components inspired by gum. Use them in your scripts to create interactive prompts, selections, and styled output.

Available Components​

ComponentDescriptionUse Case
inputSingle-line text inputNames, paths, simple values
writeMulti-line text editorDescriptions, commit messages
chooseSelect from optionsMenus, choices
confirmYes/no promptConfirmations
filterFuzzy filter listSearch through options
fileFile pickerSelect files/directories
tableDisplay tabular dataCSV, data tables
spinSpinner with commandLong-running tasks
pagerScrollable content viewerLogs, code review, long output
formatFormat text (markdown, code)Rendering content
styleStyle text (colors, bold)Decorating output

Quick Examples​

# Get user input
NAME=$(invowk tui input --title "What's your name?")

# Choose from options
COLOR=$(invowk tui choose --title "Pick a color" red green blue)

# Confirm action
if invowk tui confirm "Continue?"; then
echo "Proceeding..."
fi

# Show spinner during long task
invowk tui spin --title "Installing..." -- npm install

# Style output
echo "Success!" | invowk tui style --foreground "#00FF00" --bold

Using in Invowkfiles​

TUI components work great inside command scripts, including those running in containers with interactive mode (-i):

:::tip Container Support TUI components work seamlessly inside containers when using interactive mode. The components render as modal overlays on your host terminal. See Container Runtime - Interactive Mode for details. :::

{
name: "setup"
description: "Interactive project setup"
implementations: [{
script: {content: """
#!/bin/bash

# Gather information
NAME=$(invowk tui input --title "Project name:")
TYPE=$(invowk tui choose --title "Type:" cli library api)

# Confirm
echo "Creating $TYPE project: $NAME"
if ! invowk tui confirm "Proceed?"; then
echo "Cancelled."
exit 0
fi

# Execute with spinner
invowk tui spin --title "Creating project..." -- mkdir -p "$NAME"

# Success message
echo "Project created!" | invowk tui style --foreground "#00FF00" --bold
"""}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Common Patterns​

Input with Validation​

while true; do
EMAIL=$(invowk tui input --title "Email address:")
if echo "$EMAIL" | grep -qE '^[^@]+@[^@]+\\.[^@]+$'; then
break
fi
echo "Invalid email format" | invowk tui style --foreground "#FF0000"
done
ACTION=$(invowk tui choose --title "What would you like to do?"
"Build project"
"Run tests"
"Deploy"
"Exit")

case "$ACTION" in
"Build project") make build ;;
"Run tests") make test ;;
"Deploy") make deploy ;;
"Exit") exit 0 ;;
esac

Progress Feedback​

echo "Step 1: Installing dependencies..."
invowk tui spin --title "Installing..." -- npm install

echo "Step 2: Building..."
invowk tui spin --title "Building..." -- npm run build

echo "Done!" | invowk tui style --foreground "#00FF00" --bold

Styled Headers​

invowk tui style --bold --foreground "#00BFFF" "=== Project Setup ==="
echo ""
# ... rest of script

Piping and Capture​

The components draw their UI on your terminal (/dev/tty on Unix, the console on Windows) and read keys from it, not from stdin and stdout. stdout carries only the result, so NAME=$(invowk tui input) captures exactly the answer, with no control sequences. The UI stays visible when stderr is redirected, and stdin stays free for piped data such as filter options or table rows. format and style are the exception: their styled text is their result, so they write it to stdout.

pager and a table without --selectable only display content. When their stdout is not a terminal, they write that content to stdout and do not open the terminal: pager passes it through unchanged, like less in a pipe, and the table prints its rows as plain text.

# Pipe to filter
ls | invowk tui filter --title "Select file"

# Capture output
SELECTED=$(invowk tui choose opt1 opt2 opt3)
echo "You selected: $SELECTED"

# Pipe for styling
echo "Important message" | invowk tui style --bold

Without a Terminal​

If the controlling terminal cannot be opened, a component draws on stderr and reads keys from stdin when both are terminals. With no terminal at all, as in a CI job:

  • input, write, choose, confirm, filter, file and table --selectable exit with status 1, print an error saying the component needs a terminal, and leave stdout empty;
  • spin runs its command once, without the spinner, and keeps the command's output and exit status;
  • pager writes the content unchanged to stdout and exits 0;
  • a table without --selectable prints its rows as plain text and exits 0.

Exit Codes​

Components use exit codes to communicate:

ComponentExit 0Exit 1
confirmUser said yesUser said no
inputValue enteredCancelled
chooseOption selectedCancelled
filterOption selectedCancelled
pagerExited normallyError occurred
spinCommand succeededCancelled with Ctrl+C, the command was killed by a signal, or it was still running 15 seconds after it was stopped (any other failure forwards the command's own code)

Use in conditionals:

if invowk tui confirm "Delete files?"; then
rm -rf ./temp
fi

Next Steps​

Explore each component in detail: