Skip to main content

Install Tailwind CSS in Python projects, no NPM required.

Project description

Tailwind-Py

Tailwind-Py is a lightweight Python utility that allows you to download and use TailwindCSS without NPM. It is designed for Python web frameworks like Flask, Django, and FastAPI, making it easy to integrate Tailwind into your projects.

Inspired from the standalone published here.

Table of Contents

Install

If you have Python 3.12+ installed, you can install tailwind-py using pip:

pip install tailwind-py

After installation, you can proceed to the usage section.

Install locally

tailwind-py uses the following pre-requisites:

  • Python 3.12 or higher
  • Poetry 2.1 or higher

You will then need to clone the repo and install it using Poetry:

git clone https://github.com/your-repo/tailwind-py.git
cd tailwind-py
poetry install

Check if the CLI works.

$ tailwindcss --help

usage: tailwindcss [-h] {download,init,build} ...

Tailwind Python CLI - A tool for managing Tailwind CSS in Python projects, without npm

options:
  -h, --help            show this help message and exit

subcommands:
  {download,init,build}
                        Available commands
    download            Downloads the latest version of the TailwindCSS CLI
    init                Initialize `tailwind.config.js` file
    build               Builds the CSS output

Use 'tailwindcss <command> --help' for more information on a specific command.

Note: In the case you haven't activated your environment, you can always prefix every command with poetry run (ie. poetry run tailwindcss download)

Usage

Use tailwindcss download to download the latest version of TailwindCSS's standalone CLI, ready to use alongside this package.

Then use tailwindcss build -i "/path/to/your/input.css" -o "/path/to/your/output.css" --watch to start a watcher over the final result of your CSS file, named output.css. The input.css file is a file contaning directives for TailwindCSS. Here's an example:

@import "tailwindcss";

/* Your custom styles there */

For further details, check the official TailwindCSS documentation.

Commands

  • tailwindcss download: downloads the latest version of TailwindCSS's CLI on Github
  • tailwindcss init: writes in the current directory by default the tailwind.config.js file
  • tailwindcss build: compiles an input CSS file (typically located in your static directory) into an optimized output CSS file, ready to use in your project. Use the --watch flag for active changes and the --minify option to produce a lightweight output.

Quickstart

After installing tailwind-py, you can quickly generate a Tailwind-powered CSS file:

tailwindcss download  # Fetch the latest Tailwind CLI
tailwindcss init      # Create a default tailwind.config.js (not really needed for 4.0+)
tailwindcss build -i "static/css/input.css" -o "static/css/output.css" --watch

Then include output.css in your project:

<link rel="stylesheet" href="static/css/output.css">

Troubleshooting

Currently encountering some issues with the Linux executable when it comes to the production output.css file. The CLI doesn't show anything on stderr and considers it as mismatch, which is not the case on Windows 64.

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

tailwind_py-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

tailwind_py-0.1.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file tailwind_py-0.1.4.tar.gz.

File metadata

  • Download URL: tailwind_py-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tailwind_py-0.1.4.tar.gz
Algorithm Hash digest
SHA256 dea9be41f6fdf339b2e54a517bd1d6c9f7ac91512d642925a25e0395c080c56d
MD5 737d59fb3841c124e67fa0efffb2da40
BLAKE2b-256 41c44ac44f036197911656cb4c760cbc1097940e0a686cd9e58a338da58f2f72

See more details on using hashes here.

Provenance

The following attestation bundles were made for tailwind_py-0.1.4.tar.gz:

Publisher: python-publish.yml on sboomi/tailwind-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tailwind_py-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: tailwind_py-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tailwind_py-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 711d374d4e9b0a53bd7dc4259733f6a1aab20b9878e9b6721b5ae56a2c3c70b7
MD5 950d576f5ff2bbbf1afdd020fde43bbe
BLAKE2b-256 efa2ea33d0bb76d949906b66cf53c61d93987b8fc9714f83b45fdbd1989d18a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tailwind_py-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on sboomi/tailwind-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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