Skip to main content

Tailwind CSS for Django Crispy Forms

Project description

https://img.shields.io/badge/code%20style-black-000000.svg

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.

https://django-crispy-forms.github.io/crispy-tailwind/_images/crispy_form.png

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:

  1. Load the filter: {% load tailwind_filters %}

  2. 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:

  1. Load the crispy tag: {% load crispy_forms_tags %}

  2. Add FormHelper to your form and use crispy-forms to set-up your form

  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crispy-tailwind-1.0.1.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

crispy_tailwind-1.0.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file crispy-tailwind-1.0.1.tar.gz.

File metadata

  • Download URL: crispy-tailwind-1.0.1.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for crispy-tailwind-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4f074d94f6cb7e3bbf8577005a739cd599974e27326f61e6c00ae3c4bacd39f1
MD5 03c9d59e64d9e9c890d60fe6471bd300
BLAKE2b-256 28e0b5f99a3c5e18c3c15c6084a13395ef855db32ce0787788b52d69db26aa13

See more details on using hashes here.

File details

Details for the file crispy_tailwind-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crispy_tailwind-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00022ebad08bc859bcbfb022af1aee9d245e74209aaccf5b33089b93f9226097
MD5 662e25f974586d701bbda9ebc32a7bcc
BLAKE2b-256 b5b0daa677fc2c2c49b7233fbc646472e2144e9201b4e38a146537af87969307

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