Skip to main content

fasthtml-tailwindcss

License Release Python versions PyPI version FastHTML Tailwind CSS uv Pytest Ruff

Tailwind CSS for FastHTML with a persistent development watcher and a build command for production CSS.

Installation

  • Development and builds:

    uv add "fasthtml-tailwindcss[dev]"
    

    Or with pip:

    pip install "fasthtml-tailwindcss[dev]"
    
  • Production:

    uv add fasthtml-tailwindcss
    

    Or with pip:

    pip install fasthtml-tailwindcss
    

The dev extra installs the standalone compiler through fasthtml-tailwindcss-cli. No Node.js or npm is needed. Production only needs the wrapper and generated CSS.

On Alpine Linux, the compiler also needs:

apk add --no-cache libstdc++ libgcc

Usage

from fasthtml.common import Div, FastHTML, StaticImmutable
from fasthtml_tailwindcss import TailwindHead

app = FastHTML(hdrs=[TailwindHead(watch=True)])
app.mount("/static", StaticImmutable(directory="static"), name="static")


@app.route("/")
def get():
    return Div("Hello", cls="rounded-lg bg-blue-500 p-4 text-white")

TailwindHead creates the output directory and adds a stylesheet link. vurl versions the URL by content, and StaticImmutable lets browsers cache the CSS until it changes.

Watch mode

uv run uvicorn main:app --reload

For app/main.py, run uv run --directory app uvicorn main:app --reload from the project directory.

With watch=True, compilation starts on the first page render and CSS rebuilds when sources change. The watcher survives server reloads, restarts if settings change, and stops 15 seconds after the last application stops using it. Refresh the browser to see changes; automatic browser refresh and stylesheet updates during HTMX fragment swaps are not included.

Production

Use TailwindHead() with the default watch=False in the application, then build CSS in your deployment pipeline with the dev extra installed:

uv run fasthtml-tailwindcss build main:app

The command imports the app and builds minified CSS using its TailwindHead settings. The app must have exactly one TailwindHead in hdrs. For app/main.py, run build app.main:app from the project directory or build main:app from app/; both write to app/static/tailwind.css by default.

Deploy the generated CSS alongside the application. With watch=False, TailwindHead only links the stylesheet; it does not run the compiler.

Options

All configuration is passed to TailwindHead:

TailwindHead(
    watch=True,
    css="@theme { --color-brand: #7854f7; }",
    output="static/app.css",
)
  • watch: enable the persistent development compiler. Defaults to False.
  • sources: files or directories to scan. Defaults to the working directory; with a custom input, its own source detection applies unless extra sources are supplied.
  • input: custom stylesheet, such as input="assets/app.css", replacing the built-in @import "tailwindcss". Relative CSS imports resolve from that file.
  • css: CSS appended after the input, useful for @theme, variants, and @source inline(...).
  • output: CSS file path, defaulting to ./static/tailwind.css. The stylesheet URL follows this path, so mount its directory at the corresponding URL.

Paths are relative to the working directory. The build command uses the application module's directory; run the server from that directory too. Temporary files and compiler logs live in .fasthtml-tailwindcss/.

Use complete class names such as "bg-red-500"; Tailwind cannot detect names constructed with f"bg-{color}-500". Classes in installed component libraries need explicit sources or safelisting.

For inline Lucide SVG icons with typed names and editor autocomplete, see fasthtml-lucide.

Development

Setup and tests

uv sync --group build --group test --extra dev
uv run --group test --extra dev pytest

Build

uv build --no-sources
uv build packages/cli --no-sources

CLI wheel builds download and verify the official executable using SHA-256. Supported platforms are Linux x64/ARM64 (glibc 2.28+ or musl 1.2+), macOS 13+ (Intel/Apple Silicon), and Windows x64. Building a CLI wheel needs network access unless the verified binary is already available locally.

Automated releases

GitHub Actions checks daily for a new stable Tailwind CSS release, then builds and tests both packages before publishing them to PyPI. Both package versions track the Tailwind version; wrapper-only fixes may add a .postN suffix.

The Release workflow builds and tests both packages before publishing through PyPI Trusted Publishing. Configure the same publisher (SpaceShaman/fasthtml-tailwindcss, workflow release.yml, environment pypi) for both PyPI projects, and allow workflow version commits on the default branch.

License

The wrapper and Tailwind CSS are MIT licensed. The CLI package includes both license notices.

Metadata

Release files for fasthtml-tailwindcss 4.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fasthtml-tailwindcss 4.3.5
File Size Uploaded Provenance Actions
fasthtml_tailwindcss-4.3.5.tar.gz 17.1 kB Without provenance Details for fasthtml_tailwindcss-4.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fasthtml-tailwindcss 4.3.5
File Interpreter ABI Platform Actions
fasthtml_tailwindcss-4.3.5-py3-none-any.whl Python 3 none any Details for fasthtml_tailwindcss-4.3.5-py3-none-any.whl

Total release size: 28.6 kB

Release files / fasthtml_tailwindcss-4.3.5.tar.gz

Download URL fasthtml_tailwindcss-4.3.5.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
43df8791e77a285898f2c6fef4a67d50353670ce024ffde5c422931fc108fec8
BLAKE2b-256 checksum
How to use checksums
400fbb3511d23d9def2d89802576776ad852071911ea189713fc82f094bc2ca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fasthtml_tailwindcss-4.3.5-py3-none-any.whl

Download URL fasthtml_tailwindcss-4.3.5-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45ab6cec09c1c06a2c4c029489a7d0974489b99f20f65420458b7001ad5cfc4b
BLAKE2b-256 checksum
How to use checksums
2e6dcbdcf7fc4385edbdb8966a913e6bc06366e79d9790aec63747af85f1f0a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for fasthtml-tailwindcss 4.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page