Skip to main content

Easily use tailwind css with Flask projects

Project description

Flask-Tailwind-Manager

Flask-Tailwind-Manager provides a simple interface to use TailwindCSS with your Flask project. It will let you hide it in a folder called .tailwind so you dont have to see any node_modules or any other javascript. Even tho you DO need npm and npx to be available on your machine.

🚧 This package is under heavy development..

Installation

Install the extension with pip:

pip install flask-tailwind-manager

Configuration

This are some of the settings available. All of the configurations are optional, and in most cases it should work without any configuration.

Config Description Type Default
TAILWIND_CWD CWD for node_modules. str .tailwind
TAILWIND_OUTPUT_PATH CSS file output path inside app static. str css/style.css
TAILWIND_NPM_BIN_PATH Npm binary path. str npm
TAILWIND_NPX_BIN_PATH Npx binary path. str npx
TAILWIND_TEMPLATE_FOLDER Name of the templates folder. str templates

Usage

Once installed Flask-TailwindCSS is easy to use. Let's walk through setting up a basic application. Also please note that this is a very basic guide: we will be taking shortcuts here that you should never take in a real application.

To begin we'll set up a Flask app:

from flask import Flask
from flask_tailwind import TailwindCSS

app = Flask(__name__)

tailwind = TailwindCSS()
tailwind.init_app(app)

Using the CLI tool.

Once you completed the extension configuration, you can access the Flask-TailwindCSS CLI tool. There is 4 useful commands you will use.

  1. Installing Node and TailwindCSS basic configuration. By default this extension will generate a tailwind.config.js generic file, ready to use. If you need to futher customize you will need to edit this file accordingly.
    flask tailwind init 
  1. Once installed all modules will be found on .tailwind folder (or CWD you define). The default configuration will look for changes at {APP_NAME}/**/{TEMPLATES_FOLDER}/*{.html,.jinja,.j2}. You can always modify tailwind.config.js file in order to customize it.

  2. To start watching files and changes. use the start command as follows.

    flask tailwind start
  1. Almost every time you are using you will install plugins like Preline, Flowbite, daysiUI, etc... For this cases you can use the npx or npm commands. In the following example we will install the PrelineUI plugin as follows.
    flask tailwind npm i preline
  1. After the installation you will have to configure it manually.

This will ensure the plugins are installed in the correct CWD.

Load resources

Once the extension is set up, this will make available the tailwind_css function into the templates context so you could load the generated css like this.

<head>
  {{ tailwind_css() }} 
</head>

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

flask_tailwind_manager-0.0.16.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

flask_tailwind_manager-0.0.16-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file flask_tailwind_manager-0.0.16.tar.gz.

File metadata

File hashes

Hashes for flask_tailwind_manager-0.0.16.tar.gz
Algorithm Hash digest
SHA256 138fbf629815cd78108fc3a90909dfd3f5196503d0e7761c92b943e7e7ec9b3c
MD5 14bf55e11baa49351b84d303d6ad9a88
BLAKE2b-256 bf436684e20ee731cc1ec1468daa8880d46a8f4ec1c3c842be4ed499bf47b39a

See more details on using hashes here.

File details

Details for the file flask_tailwind_manager-0.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_tailwind_manager-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 e85fff1eb0cfb8ab7520666af1f7b520556a7495b4a861fabfbf9953b9b4c021
MD5 ae2fcdac3ebd3f596df42749cca5811d
BLAKE2b-256 0a1c36d0c1d9faa42f216535e548cecf16dfd3812ed759d9f000cbe89800f51b

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