Repository navigation
fasthtml-tailwindcss — Tailwind CSS for FastHTML with persistent watch mode #942
SpaceShaman
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone! I’d like to share fasthtml-tailwindcss, a small library for using Tailwind CSS in FastHTML, with automatic CSS rebuilds and a compiler that stays alive across server reloads.
Installation
Using uv:
Or pip:
On Alpine Linux, install the system runtime with
apk add --no-cache libstdc++ libgcc.Usage
Run your application as usual:
The package bundles the official standalone Tailwind compiler for your platform, so you don’t need Node.js, npm, a CDN, or a separate Tailwind command. Generated CSS is embedded directly in the page’s
<head>.Watch mode and server reloads
With
watch=True, Tailwind watches your source files and rebuilds CSS as classes change. The compiler keeps running across Uvicorn reloads, so restarting the application process doesn’t start another watcher or trigger another initial build.Each full page receives the latest completed CSS. Refresh the browser to see changes; browser live reload and updating styles during HTMX fragment swaps aren’t included.
With
watch=False, CSS is built once with minification and reused across server reloads during the same session.Customization
You can pass source paths, extra CSS, or a custom input stylesheet directly to
TailwindHead:Automatic updates
A daily GitHub Actions workflow checks for new stable Tailwind releases, builds and tests the platform wheels, and publishes updates to PyPI.
The PyPI version matches the bundled Tailwind release. Python-only fixes use a
.postNsuffix while keeping the same Tailwind compiler.Links
Feedback and suggestions are welcome!
All reactions