Skip to main content

Integrate Tailwind CSS without JavaScript or npm.

Project description

plain.tailwind

Integrate Tailwind CSS without JavaScript or npm.

Overview

This package allows you to use Tailwind CSS in your Plain project without requiring Node.js or npm. It uses the Tailwind standalone CLI, which is automatically downloaded and managed for you.

First, initialize Tailwind in your project:

plain tailwind init

This creates a tailwind.config.js file in your project root and a source CSS file.

Then compile your CSS:

plain tailwind build

For development, use watch mode to automatically recompile when files change:

plain tailwind build --watch

Include the compiled CSS in your templates:

{% tailwind_css %}

Basic Usage

Commands

The plain tailwind command provides several subcommands:

$ plain tailwind
Usage: plain tailwind [OPTIONS] COMMAND [ARGS]...

  Tailwind CSS

Options:
  --help  Show this message and exit.

Commands:
  build    Compile a Tailwind CSS file
  init     Install Tailwind and create tailwind.css
  install  Install the Tailwind standalone CLI
  update   Update the Tailwind CSS version
  • init - Sets up Tailwind in your project, creating necessary config files
  • build - Compiles your Tailwind CSS (use --watch for auto-compilation, --minify for production)
  • update - Updates to the latest version of Tailwind CSS
  • install - Manually install the Tailwind CLI (usually automatic)

Template Tag

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>
    <!-- Your content -->
</body>
</html>

Configuration

Updating Tailwind

The package tracks the Tailwind version in your pyproject.toml:

# pyproject.toml
[tool.plain.tailwind]
version = "3.4.1"

When you run plain tailwind build, it automatically checks if your local installation matches this version and updates if needed.

To update to the latest version:

plain tailwind update

This downloads the latest version and updates your pyproject.toml.

Adding Custom CSS

Custom CSS should be added to your source CSS file (by default at the root of your project as tailwind.css):

@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 →

Deployment

For production deployments:

  1. Add app/assets/tailwind.min.css to your .gitignore
  2. Run plain tailwind build --minify as part of your deployment process

The build command automatically installs the Tailwind CLI if it's not present, making deployments seamless.

Installation

Install the plain.tailwind package from PyPI:

uv add plain.tailwind

Then add to your INSTALLED_PACKAGES:

# settings.py
INSTALLED_PACKAGES = [
    # ...
    "plain.tailwind",
]

The package stores the Tailwind CLI binary and version information in a .plain directory. Add this to your .gitignore:

.plain/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plain_tailwind-0.16.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plain_tailwind-0.16.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file plain_tailwind-0.16.0.tar.gz.

File metadata

  • Download URL: plain_tailwind-0.16.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_tailwind-0.16.0.tar.gz
Algorithm Hash digest
SHA256 276b65e3af95feb1e1f958838def4ddbbe2d2f6d44d993d467fe9d03b8cce0d9
MD5 f7d1939a976d1ecb54224fab27e1115d
BLAKE2b-256 1bbcd55de969ac8c78cb968853c9b10efcc89bf9717d875bf966e64dbe806cb9

See more details on using hashes here.

File details

Details for the file plain_tailwind-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: plain_tailwind-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for plain_tailwind-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78103eb98d9b795469a6e4d6fbffea997a605bdf443a1626b16680a4f5e11f11
MD5 e91d2258bf11188d5b9a2d2181d89572
BLAKE2b-256 1d34df7eaaa7d402a8f0cec95100f9cfdaa001d726e2921c44a215d84c0bfe35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page