Tailwind CSS Laravel Package

Packages

February 4th, 2022

Tailwind CSS Laravel Package

The Tailwind CSS Laravel package from Tony Messias wraps up the standalone CLI version of the Tailwind CSS framework for Laravel applications.

If you're not familiar with the purpose of the Tailwind CSS standalone CLI, the announcement about it explains:

Tailwind CSS is written in JavaScript and distributed as an npm package, which means you’ve always had to have Node.js and npm installed to use it.

This has made it harder to integrate into projects where using npm isn’t always common, and with tools like Rails and Phoenix both moving away from npm by default, we needed to find a way for people to use Tailwind in these projects without forcing them to adopt an entirely separate ecosystem of tooling.

Today we’re announcing a new standalone CLI build that gives you the full power of Tailwind CLI in a self-contained executable — no Node.js or npm required.

This package provides convenient commands such as installing, scaffolding, building, and minifying Tailwind builds via the standalone CLI:

# Download the correct CLI based on OS/CPU arch
php artisan tailwindcss:download
 
# Install the scaffolding (tailwindcss.config.js, app.css, etc.)
php artisan tailwindcss:install
 
# Build styles
php artisan tailwindcss:build [--digest|--minify]
 
# Watch for changes during development
php artisan tailwindcss:watch

Lastly, this package also comes with a tailwindcss() helper function to render the compiled assets instead of mix() for node.js environments:

<link rel="stylesheet" href="{{ tailwindcss('css/app.css') }}" >

You can learn more about this package, get full installation instructions, and view the source code on GitHub at tonysm/tailwindcss-laravel.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.