Skip to main content

Integrate Tailwind CSS with Plain.

Project description

plain.tailwind

Integrate Tailwind CSS without JavaScript or npm.

Made possible by the Tailwind standalone CLI, which is installed for you.

$ 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, create a tailwind.config.js...
  update   Update the Tailwind CSS version

Installation

Add plain.tailwind to your INSTALLED_PACKAGES:

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

Create a new tailwind.config.js file in your project root:

plain tailwind init

This will also create a tailwind.css file at at the root of your repo.

The tailwind.css file is then compiled into app/assets/tailwind.min.css by running tailwind build:

plain tailwind build

When you're working locally, add --watch to automatically compile as changes are made:

plain tailwind build --watch

Then include the compiled CSS in your base template <head>:

{% tailwind_css %}

In your repo you will notice a new .plain directory that contains tailwind (the standalone CLI binary) and tailwind.version (to track the version currently installed). You should add .plain to your .gitignore file.

Updating Tailwind

This package manages the Tailwind versioning by comparing the value in your pyproject.toml to .plain/tailwind.version.

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

When you run tailwind compile, it will automatically check whether your local installation needs to be updated and will update it if necessary.

You can use the update command to update your project to the latest version of Tailwind:

plain tailwind update

Adding custom CSS

If you need to actually write some CSS, it should be done in app/static/src/tailwind.css.

@tailwind base;


@tailwind components;

/* Add your own "components" here */
.btn {
    @apply bg-blue-500 hover:bg-blue-700 text-white;
}

@tailwind utilities;

/* Add your own "utilities" here */
.bg-pattern-stars {
    background-image: url("/static/images/stars.png");
}

Read the Tailwind docs for more about using custom styles →

Deployment

If possible, you should add app/assets/tailwind.min.css to your .gitignore and run the plain tailwind build --minify command as a part of your deployment pipeline.

When you run plain tailwind build, it will automatically check whether the Tailwind standalone CLI has been installed, and install it if it isn't.

When using Plain on Heroku, we do this for you automatically in our Plain buildpack.

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.13.1.tar.gz (5.7 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.13.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: plain_tailwind-0.13.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.15

File hashes

Hashes for plain_tailwind-0.13.1.tar.gz
Algorithm Hash digest
SHA256 5ebd2d406e0955dfca4394e9ffc9e51e8f3e6825b8f073a0f4a53a550b7a6fa7
MD5 5a1582038a5fa647dd62590f629a4bfe
BLAKE2b-256 9f25f673ae63f3fb4a309cb79a7f16c61129d23ea6f4b02ad88c5aa7ee62a370

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for plain_tailwind-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa07ffbda3a8bec62264170afebf5520b3b65bb55b76fcb83c1c3ae411727ad2
MD5 a5a08f049e5e4625a62da9e670759a58
BLAKE2b-256 6eef6046b1aa59ab2a693c3e9592e79dd82c5d6e0e6cb079c408ec97992ef6e1

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