skillfed

django-components

A way to create simple reusable template components in Django.

django-components v0.151.1 160.6K downloads/30d#10,655 on PyPI
Permissive license MIT Active released

What it is and what it does

django-components is a UI framework that brings component-based architecture to Django templates. It lets you define reusable components as Python classes, each bundling its own HTML template, CSS styles, and JavaScript behavior into a single, self-contained unit. You register a component once and then use it anywhere in your templates via a simple tag syntax, passing data and slots just like in modern frontend frameworks.

The package extends Django's template system with Python expressions, literal data structures, spread operators, and slot-based composition, making it possible to build modular interfaces without leaving Django. Components can load their assets from files or define them inline, and they support dynamic data binding through get_template_data, get_js_data, and get_css_data methods. It's designed for projects of any size and is tested across major browsers.

Use it for:

  • Build a reusable product card component that encapsulates display logic, styling, and interactivity in one place.
  • Create a form component library where each field type (text input, dropdown, checkbox) is self-contained with its own validation and styling.
  • Compose page layouts using slot-based components to share headers, sidebars, and footers across templates.
  • Develop a design system where UI patterns (buttons, modals, tables) are versioned and shared across multiple Django projects.
  • Reduce template duplication by extracting repeated HTML/CSS/JS patterns into registered components.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

django-components lets you build reusable, self-contained UI components in Django that bundle HTML, CSS, and JavaScript together, similar to Vue or React components but staying within the Django ecosystem.

Yes. django-components is actively maintained, has low install friction, carries a permissive MIT license, and solves a real problem—modular UI composition in Django—without requiring you to leave the Django ecosystem or adopt a separate frontend build system. It's suitable for both small and large projects and has no known security vulnerabilities.

Install

django-components on PyPI

pip

pip install django-components

uv

uv add django-components

poetry

poetry add django-components

Installing django-components

Before you install

Low friction install with a pure-Python wheel. Actively maintained with a release within the last 50 days. Depends on Django, djc-core, and typing-extensions—all standard, lightweight dependencies.

License in practice

MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.

Quickstart

pip install django-components

from django_components import Component, register

@register("my_component")
class MyComponent(Component):
    template = "<div>{{ message }}</div>"
    def get_template_data(self, args, kwargs, slots, context):
        return {"message": kwargs.get("message", "Hello")}

# In template: {% component "my_component" message="World" %}

Requires Django 5.2 or 6.0 and Python 3.10 or later; must be installed in a Django project.

Verify before relying

  • Performance characteristics when rendering many components or deeply nested component trees.
  • Browser compatibility details beyond the stated testing across Chromium, Firefox, and WebKit.
  • Whether djc-core is a separate package or an internal dependency, and what it provides.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — Django, djc-core, typing-extensions
Maintenance actively maintained — 50 days since the last release
First released
Downloads 160,562/month — #10,655 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_components-0.151.1-py3-none-any.whl

Keywords: django, components, css, js, html

Framework :: DjangoFramework :: Django :: 5.2Framework :: Django :: 6.0Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

django reusable componentsdjango ui frameworkdjango template componentsdjango modular uidjango component librarydjango vue-like componentsdjango self-contained templates
django-frameworkui-componentstemplate-system

More Application Frameworks packages