Django HTMX Components Made with 🦎 by Iwana Labs

What

This is a collection of components for Django and htmx. They are designed to be copy-pasted into your project and customized to your needs.

They feature minimal styling and barebones functionality. They are meant to be a starting point for your own components or a reference.

List of components

These are the components we've created so far:

  • Active Search
  • Bulk Update
  • Cascading Selects
  • Click to Edit
  • Click to Load
  • Delete Row
  • Edit Row
  • Infinite Scroll
  • Inline Validation
  • Progress Bar

Contributing

We'd love to see your components here! If you have a component you'd like to share, please go to our GitHub repository and open a pull request.

How

It's easy! Just copy and paste these components into your project. They serve as a starting point for your own components or as a reference.

To use them, you first need to install some dependencies. Here's how to do it:

  1. Install Django and htmx.
  2. Install and set up django-components.
  3. Create a urls.py file in components/ and add the following code:
    
                                        from django.urls import path 
                                        urlpatterns = []
                                    
    Then import this file in your project's urls.py file:
    
                                        from django.urls import path, include
                                        urlpatterns = [
                                            path('components/', include('components.urls')),
                                        ]
                                    
    This step simplifies adding URL patterns for your components and keeps them separate from your project's URL patterns. Then, adding a single-file component to your components/urls.py file is as easy as:
    
                                        from django.urls import path
                                        from components.mycomponent import MyComponent 
                                        urlpatterns = [
                                            path('mycomponent/', MyComponent.as_view()),
                                        ]
                                    
    It will handle requests to /components/mycomponent/ and render the component.
  4. That's all! You can now use the component in your templates. Check out the examples to get started.