A tailwind package for Django Crispy Forms
Project description
A Tailwind CSS template pack for the wonderful django-crispy-forms.
WARNING
This project is still in its early stages of development. Any contributions to the package would be very welcomed.
Currently the template pack allows the use of the |crispy filter to style your form. Here is an example image.
How to install
Install via pip.
pip install crispy-tailwind
You will need to update your project’s settings file to add crispy_forms and crispy_tailwind to your project’s INSTALLED_APPS setting. Also set tailwind as an allowed template pack and as the default template pack for your project:
INSTALLED_APPS = ( ... "crispy_forms", "crispy_tailwind", ... ) CRISPY_ALLOWED_TEMPLATE_PACKS = "tailwind" CRISPY_TEMPLATE_PACK = "tailwind"
How to use
This project is still in its early stages.
Current functionality allows the |crispy filter to be used to style your form. In your template:
Load the filter: {% load tailwind_filters %}
Apply the crispy filter: {{ form|crispy }}
We can also use the {% crispy %} tag to allow usage of crispy-forms’ FormHelper and Layout. In your template:
Load the crispy tag: {% load crispy_forms_tags %}
Add FormHelper to your form and use crispy-forms to set-up your form
Use the crispy tag {% crispy form %} in your template
Documentation
The documentation for this project is available here: https://django-crispy-forms.github.io/crispy-tailwind/index.html
FAQs
What about custom widgets?
The template pack includes default styles for widgets included in Django itself. Styling of widget instances can be done by using the widget.attrs argument when creating the widget.
For example the following form will render <input type="text" name="name" class="customtextwidget custom-css" required id="id_name">:
class CustomTextWidget(forms.TextInput): pass class CustomTextWidgetForm(forms.Form): name = forms.CharField( widget=CustomTextWidget(attrs={"class": "custom-css"}) )
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 crispy-tailwind-1.0.0.tar.gz
.
File metadata
- Download URL: crispy-tailwind-1.0.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 947e1125faad2e3b1bf678204e37f847b36749c1c274fc8d82e57ff74aa96945 |
|
MD5 | 5e76b31c332639d4664c3a51c2b711f6 |
|
BLAKE2b-256 | 7205909a6b62427101561d1d273a5317d7bdc40f6d84d415ad7733654ffb59ee |
File details
Details for the file crispy_tailwind-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: crispy_tailwind-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cae27002f26212b2ced5bbc253062af1fd6a1b71e2b25a88720b5ca9b306572 |
|
MD5 | 4aa4e01b4b558a758fd4c44937553d76 |
|
BLAKE2b-256 | 8ee8092cff76f59518b49611337919ff5ae92d70d7271fcf497b4a1d6e48abb4 |