nunomaduro/termwind
Termwind brings Tailwind CSS-style utilities to PHP CLIs. Render styled HTML in the terminal, customize styles/colors, and build beautiful output for Laravel/Symfony commands with helpers like render(), style(), and interactive prompts like ask().
Install with composer require nunomaduro/termwind, then start rendering styled CLI output using HTML-like syntax with Tailwind-style utility classes. The fastest way to get going is using the render() helper with inline HTML or Blade views. For basic scripts, import Termwind\render and call it with a string containing a <div>, <p>, or other supported elements—add Tailwind classes for colors, spacing, and layout. In Laravel or Symfony console commands, inject or import render() and use it inside the handle() method to render styled output or Blade views—just like you would render an HTML page, but for the terminal.
Developers commonly use render() to build rich CLI dashboards, progress indicators, debug tools, and documentation generators. A typical workflow includes:
resources/views/termwind/summary.blade.php) and calling render(view(...)).style() to register project-specific class aliases (e.g. style('btn') → "p-2 bg-blue-500 text-white font-bold") for consistent theming.ask() with styled prompts and autocompletion for interactive CLI apps.terminal() methods (->width(), ->clear()) with responsive classes (sm:bg-green-500 md:bg-blue-500) to adapt layouts across terminal sizes.flex, space-y-2, justify-between) to simulate web-like interfaces in the terminal.For testing, use render() in tests alongside PHPUnit’s output capture, or pass custom output handlers for deterministic assertions.
color-support in Laravel, StreamOutput::setDecorated(true), or use symfony/stopwatch with colored output).render() only affects output when verbosity is NORMAL or higher—use ->withException() or ->handle() wrappers in tests where output capture is needed..truncate) breaks layout if used alongside %-based widths; prefer fixed widths (w-60, w-1/2) or w-full for predictable results.view('termwind.foo') expects resources/views/termwind/foo.blade.php, and variables must be explicitly passed to render().sm:text-green-500) only apply if the terminal width crosses their thresholds (64/76/102/etc. columns); set TERMINAL_WIDTH environment variable for consistent local testing.ask() supports auto-completion only for options passed via the choices array—provide a non-empty array for reliable UX.<a> inside <li>)—Termwind enforces child validity and throws InvalidChild exceptions.How can I help you explore Laravel packages today?