Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Termwind Laravel Package

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().

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

Developers commonly use render() to build rich CLI dashboards, progress indicators, debug tools, and documentation generators. A typical workflow includes:

  • Building reusable components using Blade views (e.g. resources/views/termwind/summary.blade.php) and calling render(view(...)).
  • Using style() to register project-specific class aliases (e.g. style('btn')"p-2 bg-blue-500 text-white font-bold") for consistent theming.
  • Leveraging ask() with styled prompts and autocompletion for interactive CLI apps.
  • Combining terminal() methods (->width(), ->clear()) with responsive classes (sm:bg-green-500 md:bg-blue-500) to adapt layouts across terminal sizes.
  • Creating “card” or “panel” layouts with flexbox (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.

Gotchas and Tips

  • Color support relies on the underlying terminal’s ANSI capabilities: Windows users may need to enable ANSI support (color-support in Laravel, StreamOutput::setDecorated(true), or use symfony/stopwatch with colored output).
  • By default, render() only affects output when verbosity is NORMAL or higher—use ->withException() or ->handle() wrappers in tests where output capture is needed.
  • Truncation (.truncate) breaks layout if used alongside %-based widths; prefer fixed widths (w-60, w-1/2) or w-full for predictable results.
  • When using Blade views, ensure the view path is registered correctly—view('termwind.foo') expects resources/views/termwind/foo.blade.php, and variables must be explicitly passed to render().
  • Responsive classes (e.g. 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.
  • Don’t nest unsupported tags (e.g. <a> inside <li>)—Termwind enforces child validity and throws InvalidChild exceptions.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport