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 configured your environment as

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.3.tar.gz (8.5 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.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tailwind_py-0.1.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.3 Windows/10

File hashes

Hashes for tailwind_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 03e254164b2c41554cbdfd2389c9a8751feb2c16511f33e1051034f7c290be50
MD5 ce37b9a7fd3727d4998df09bed2bcd39
BLAKE2b-256 aaf6d6476789e138b7d79ca9003f53feafd4176a5f018cbc42f0823f63fb0862

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tailwind_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.3 Windows/10

File hashes

Hashes for tailwind_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f0cd78f27906534d4b284b75e60b44f89e6aae57a11ebbceef23b834c52bd4d8
MD5 e08e2dcfd386a1f8ee77e6cb629b21f7
BLAKE2b-256 82ea051b2cb7c757aab31e9fde14b78292b9c36d51a31400312585e4427c6acd

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