Integrate Tailwind CSS without JavaScript or npm.
You can use Tailwind CSS in your Plain project without Node.js or npm. This package automatically downloads and manages the Tailwind standalone CLI for you.
Initialize Tailwind in your project:
plain tailwind initThis creates a tailwind.css source file in your project root. Then compile your CSS:
plain tailwind buildFor development, use watch mode to automatically recompile when files change:
plain tailwind build --watchInclude the compiled CSS in your templates:
<!DOCTYPE html>
<html>
<head>
{% tailwind_css %}
</head>
<body>
<h1 class="text-3xl font-bold text-blue-600">Hello, Tailwind!</h1>
</body>
</html>Sets up Tailwind in your project. This command:
- Downloads the Tailwind standalone CLI (if not already installed)
- Creates a
tailwind.csssource file in your project root
plain tailwind initCompiles your Tailwind CSS from the source file to app/assets/tailwind.min.css.
# One-time build
plain tailwind build
# Watch mode for development
plain tailwind build --watch
# Minified build for production
plain tailwind build --minifyThe build command automatically installs or updates the Tailwind CLI if needed.
Updates to the latest version of Tailwind CSS:
plain tailwind updateThis downloads the newest version and updates your pyproject.toml.
The tailwind_css template tag includes the compiled CSS file in your templates. Place it in your base template's <head>:
<!DOCTYPE html>
<html>
<head>
{% tailwind_css %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>The tag renders a <link> element pointing to your compiled CSS file.
| Setting | Default | Env var |
|---|---|---|
TAILWIND_SRC_PATH |
<project>/tailwind.css |
- |
TAILWIND_DIST_PATH |
app/assets/tailwind.min.css |
- |
See default_settings.py for more details.
The Tailwind version is tracked in your pyproject.toml:
[tool.plain.tailwind]
version = "4.0.0"When you run plain tailwind build, it automatically checks if your local installation matches this version and updates if needed.
Add custom CSS to your source file (by default tailwind.css at the project root):
@import "tailwindcss";
@import "./.plain/tailwind.css";
/* Add your custom styles here */
.btn-primary {
@apply bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded;
}
.custom-gradient {
background: linear-gradient(to right, #4f46e5, #7c3aed);
}The @import "./.plain/tailwind.css" line includes styles from all your installed Plain packages.
Read the Tailwind docs for more about using custom styles.
Plain packages can contribute CSS to your Tailwind build by shipping a
tailwind.css file next to their __init__.py. If the file exists, an
@import for it is automatically added to .plain/tailwind.css — no user
configuration required.
Use it for design tokens (@theme), component layers (@apply-based rules
inside @layer components), @custom-variants, or anything else that needs
to be part of the Tailwind compilation rather than a separate <link>.
/* my-package/plain/my_package/tailwind.css */
@theme {
--color-brand: oklch(0.5 0.15 250);
}
@layer components {
.my-callout {
@apply rounded-md border border-brand bg-brand/10 p-4;
}
}The file path is relative to the package's Python directory. To split content
across multiple files, use @import inside tailwind.css:
@import "./assets/components.css";
@import "./assets/tokens.css";plain-admin uses this pattern to integrate its vendored Basecoat UI
components — see plain.admin's component system.
For production deployments:
- Add
app/assets/tailwind.min.cssto your.gitignore - Run
plain tailwind build --minifyas part of your deployment process
The build command automatically installs the Tailwind CLI if it is not present, making deployments seamless.
You can automate this by adding a build command to your pyproject.toml:
[tool.plain.assets.run]
tailwind = {cmd = "plain tailwind build --minify"}Tailwind provides a standalone CLI that bundles everything needed to compile CSS. This package downloads the appropriate binary for your platform (macOS, Linux, or Windows) and manages it for you.
The Tailwind binary and version information are stored in a .plain directory in your project root. Add this to your .gitignore:
.plain/
The @import "./.plain/tailwind.css" line in your source CSS automatically includes @source directives for all installed Plain packages. This ensures Tailwind scans those packages for class usage.
The standalone CLI includes all first-party plugins. For third-party plugins that require npm, you would need to use the standard Tailwind installation instead.
Install the plain.tailwind package from PyPI:
uv add plain.tailwindAdd plain.tailwind to your INSTALLED_PACKAGES:
# app/settings.py
INSTALLED_PACKAGES = [
# ...
"plain.tailwind",
]Add .plain/ to your .gitignore:
.plain/
Initialize Tailwind in your project:
plain tailwind initAdd the tailwind_css template tag to your base template:
<!DOCTYPE html>
<html>
<head>
{% tailwind_css %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>Run the build command to compile your CSS:
plain tailwind build --watch