Skip to main content

Playground

Runnable examples live in playground/ - one directory per feature, numbered in learning order, from the quick start to a capstone form that composes everything:

DirectoryDemonstrates
01-quickstartThe fluent builder and run() - the form from the quick start
02-widgetsOne script per widget, plus the whole gallery on one form
03-panelsNested panels, modal dialogs and the border frame
04-inline-editingInline editing and ->standalone()
05-headlessUnattended collection, the JSON schema, validation, agent help
06-form-logicDerived values, conditional fields, fix-ups
07-field-behaviourDeclared behaviour: closures and handler classes
08-discoveryDiscovery against a bundled sample project
09-themesThe built-in themes, a custom theme class, theme options, field styles
10-key-bindingsKey bindings: the vim preset and per-binding overrides
11-display-modesDisplay modes: dark/light, ASCII, no colour
12-testingThe test harness driving the TUI from scripted keystrokes
13-translationsTranslations through a consumer catalog
14-produce-boxThe capstone: panels, widgets, logic and behaviour in one real form

Every script is self-contained - it requires the Composer autoloader directly and declares its whole form inline, so any single file can be copied out as a starting point. No script takes CLI options: each demonstrates exactly one thing, variants are separate scripts, and unattended runs are driven by piping stdin and setting TUI_<ID> environment variables.

composer install
php playground/01-quickstart/run.php

The SVG demos throughout this documentation are generated from the playground scripts and forms: php docs/util/update-assets.php records the panel walkthroughs through a scripted terminal session (requires asciinema, expect, node and npm), while php docs/util/render-widget-svgs.php and php docs/util/render-theme-svgs.php render the widget cards and theme previews deterministically through the library's own test harness - no terminal involved.