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.
- 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
-
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 modifytailwind.config.js
file in order to customize it. -
To start watching files and changes. use the
start
command as follows.
flask tailwind start
- Almost every time you are using you will install plugins like Preline, Flowbite, daysiUI, etc... For this cases you can use the
npx
ornpm
commands. In the following example we will install the PrelineUI plugin as follows.
flask tailwind npm i preline
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask_tailwind_manager-0.0.10.tar.gz
.
File metadata
- Download URL: flask_tailwind_manager-0.0.10.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 323607f56efae92a85c5238ec45a98a3ffb97c137f7de9d951806d97043333e8 |
|
MD5 | b672e792491060e705273c6e5b2d09ad |
|
BLAKE2b-256 | fb01b7592a7e97a0337f7b61b8c4c5fec48a9d0acbe16427beda50fa8716c2dd |
File details
Details for the file flask_tailwind_manager-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: flask_tailwind_manager-0.0.10-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df9c6bd4196129b2fe2665c7191b107620103226df1fcb2b0976effd6cbcb38 |
|
MD5 | 0f0b42c63e5ba10b0b5a97a0967184d2 |
|
BLAKE2b-256 | 3c22740487c6c2720bda2f1ef6535cd9a706b734a6ffe722c396a6c5118a6b3a |