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.

Usage

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

Then use tailwind 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

  • tailwind download: downloads the latest version of TailwindCSS's CLI on Github
  • tailwind init: writes in the current directory by default the tailwind.config.js file
  • tailwind 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:

tailwind download  # Fetch the latest Tailwind CLI
tailwind init      # Create a default tailwind.config.js (not really needed for 4.0+)
tailwind 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">

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.2.tar.gz (8.3 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.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tailwind_py-0.1.2.tar.gz
  • Upload date:
  • Size: 8.3 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.2.tar.gz
Algorithm Hash digest
SHA256 e611ba35d12c5b9488ebaab68062e9f71eaad64937d7982b85bafbab08ecd6a4
MD5 b9daa33ec13c159026275b7c8ce9ccc5
BLAKE2b-256 d3de64f28d929d53c1965aa502b71796eb1f2fdf5e4d61693417c83477003569

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tailwind_py-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc71851b13298c0643fc855e81417d5dd51707daa442e48fefbab0e88efe2616
MD5 9d8e9b8358279684254be49e671da08c
BLAKE2b-256 a806b2b7d20d39c51703f2c2fb5a1b41eb9b11abede562e4886fbb8e35bea4c2

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