Forms & Schema Validation
tui.zig pairs interactive form controls (TextInput, TextArea, Checkbox, RadioGroup, Select, Switch, Slider, Button) with stack-allocated schema validation (tui.schema) so validation runs smoothly on every keystroke without heap allocations.
Single-Line Input & Hardware Cursor
When .focused = true, TextInput and TextArea scroll horizontally/vertically to keep the caret inside view, highlight active text selections (Shift+Left/Right/Home/End, Ctrl+A), support Ctrl+Left/Right word jumps and Ctrl+K/Ctrl+U/Ctrl+W editing shortcuts, and automatically call ui.setCursor(x, y) (pairable with .cursor_shape = .blinking_bar in tui.init).
const EmailSchema = tui.schema.email(.{});
var err_buf: [128]u8 = undefined;
const check = state.email.validateWithSchema(EmailSchema, &err_buf);
const status: tui.ValidationStatus = if (state.email.text().len == 0)
.none
else if (check.valid)
.valid
else
.invalid;
try ui.textInput(.{
.label = "Work Email",
.placeholder = "alex@company.com",
.focused = state.focus.isFocused(0),
.validation = status,
.error_message = check.message,
}, &state.email, null);Interactive State Controls & Mouse Support
TextInput(TextInput.handleEvent): Supports click-to-cursor placement, left-button drag text selection,.disabledguard, and automatic newline/tab space normalization on insert/paste.TextArea(TextArea.handleEvent): Supportsselection_anchor,Shift+Arrows/Home/Endselection ranges,Ctrl+A,selectedText,deleteSelection,tab_sizeexpansion (visualWidthWithTabs), andread_onlymode.Slider(Slider.handleEvent): Supports.disabled, fractional.precision, suffix.unit, and mouse drag/click aligned cleanly toSlider.trackRect.RadioGroup: Supports vertical rows or horizontal items with automatic row wrapping (.wrap = true).Select/Dropdown: Supports.disabled, type-ahead search, keyboard/wheel scrolling, and edge-clamped popup shadows (DropdownandDropdownStatealiases).
Presets & Masking
tui.TextInput.search("Search files..."): adds a🔍prefixtui.TextInput.command("Run command..."): adds a>prompt prefixtui.TextInput.secret("API Token"): masks UTF-8 graphemes with"•"while keeping raw input bytes inTextInputState
Built-in Validation Combinators
Common validators on tui.schema (string, email, url, integer, objectOf, withDefault) check length bounds, formats, and defaults directly on caller stack slices.