Skip to main content

Tailwindcss component tags for Django Projects.

Project description

Test Status:
GitHub Workflow Status
Version Info:
PyPI PyPI - Downloads
Compatibility:
https://img.shields.io/pypi/pyversions/django-component-tags-tailwindcss?style=flat-square&label=Python%20Versions PyPI - Django Version

Tailwindcss component tags for Django Projects.

Description

Django template tags based on Tailwindcss, created with django-component-tags.

Tailwind is an utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.

Requirements

Requires Django 2.2 or newer, and is tested against Python 3.7 and PyPy.

Quick Start

Install the python package django-component-tags-tailwindcss from pip:

pip install django-component-tags-tailwindcss

Add it to INSTALLED_APPS in your settings.py:

INSTALLED_APPS = [
    ...
    'component_tags',
    'component_tags_tailwindcss',
    ...
]
...

Next, create your own base template:

# templates/index.html
{% load static %}
{% load tailwindcss_component_tags %}
<!DOCTYPE html>
<html lang="en">
{% block head %}
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>-----</title>
        <!-- Styles -->
        <link rel="stylesheet" href="{% static 'component_tags_tailwindcss/css/tailwind.min.css' %}">
        {% components_css %}
    </head>
{% endblock head %}
<body>
{% block content %}{% endblock content %}
<!-- Scripts -->
{% components_js %}
</body>
</html>

After loading the tailwindcss_component_tags library you will be able to use any of the available components inside any template.

Optional: You can use the provided base template for a quick setup from component_tags_tailwindcss/base.html:

# templates/index.html
{% extends 'component_tags_tailwindcss/base.html' %}
{% load tailwindcss_component_tags %}

{% block content %}
    Content goes here...
{% endblock content %}

We encourage you to make your own installation of Tailwindcss, do not use this base template on production environments.

Components

  • Link

  • Alert*

  • Breadcrumb

  • Button

  • Card

  • Dropdown*

  • Label

  • Modal*

Some components marked with * require javascript, therefore i choose AlpineJS to make the minimal javascript logic.

You can of course extend this components and implement your own javascript framework.

Examples

Here we have just a couple of examples to showcase the code. Checkout this template if you want to get more examples.

Alert

# templates/index.html
{% extends 'component_tags_tailwindcss/base.html' %}
{% load tailwindcss_component_tags %}

{% block content %}
    {% alert %}Link 1{% endalert %}
    {% alert color="primary" %}Primary link{% endalert %}
    {% alert color="danger" %}Secondary Link{% endalert %}
{% endblock %}

Card

# templates/index.html
{% extends 'component_tags_tailwindcss/base.html' %}
{% load tailwindcss_component_tags %}

{% block content %}
    {% card %}
        {% slot 'header' %}
            <img class="w-full"
                 src="https://images.unsplash.com/photo-1593642634524-b40b5baae6bb?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2089&q=80"
                 alt="card-logo">
        {% endslot %}
        Card body
    {% endcard %}
{% endblock %}

Note

This project has been set up using PyScaffold 4.0rc2. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

Built Distribution

django_component_tags_tailwindcss-0.0.3-py2.py3-none-any.whl (2.8 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file django_component_tags_tailwindcss-0.0.3.tar.gz.

File metadata

  • Download URL: django_component_tags_tailwindcss-0.0.3.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for django_component_tags_tailwindcss-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5c24d7d7858f2fab199e28ea8478fac884079dee78e37a7bd9f2f3086bfa8206
MD5 1495b77a95b9525aec8cc8b1ab6f6a9e
BLAKE2b-256 f91cee9fde8352b88284a761bc99ba337bb36a079282e9fc675fba872f6ef57a

See more details on using hashes here.

File details

Details for the file django_component_tags_tailwindcss-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_component_tags_tailwindcss-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f284f4c8c18f89a89bcb0ef69bc124f36160156413a697722d960860320d0b8
MD5 b62429e84223ee4e751634aedda930e1
BLAKE2b-256 c6c846ce97d2484f6562102ff8c9af264cd0fff3682e26e3e3858058d21c35a0

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