--- id: django-components version: "0.151.1" license: MIT license_treatment: permissive maintenance: active --- # django-components — A way to create simple reusable template components in Django. License: permissive · Maintenance: active · Downloads: 160.6K/mo ## 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 above — 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 pip install django-components uv add django-components 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 = "