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:
  compile  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 static/src/tailwind.css where additional CSS can be added. You can customize where these files are located if you need to, but this is the default (requires STATICFILES_DIR = BASE_DIR / "static").

The src/tailwind.css file is then compiled into dist/tailwind.css by running tailwind compile:

plain tailwind compile

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

plain tailwind compile --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 static/dist/tailwind.css to your .gitignore and run the plain tailwind compile --minify command as a part of your deployment pipeline.

When you run plain tailwind compile, 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.3.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

plain_tailwind-0.3.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: plain_tailwind-0.3.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for plain_tailwind-0.3.1.tar.gz
Algorithm Hash digest
SHA256 98d3190c19ed36bcee752a039f2a57dc18ab61c0102c1e156ea6e688ccda4c4c
MD5 d0a1041f62be5dd4ebd3ca70f990820e
BLAKE2b-256 ad87247733c2e5cb5dd78bd5717eaae5c8985ed71c8ee343bcf5e96ffdfca41a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: plain_tailwind-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for plain_tailwind-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a196e3bf16b91deb96c5439d0f0102f3de73a034a7060bc26050fa8bd9b4b105
MD5 690c0be277b5b15f766cb4660f5f91e3
BLAKE2b-256 8691bd2b34b0555a4fdde4c3059d46999001b3de44446c4fab2c23a1442a9387

See more details on using hashes here.

Supported by

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