PyJinHx¶
Build reusable, type-safe UI components for template-based web apps in Python.
PyJinHx combines Pydantic models with Jinja2 templates to give you template discovery, component composition, and JavaScript bundling.
Features¶
- Automatic Template Discovery - Place templates next to component files, no manual paths needed
- Composability - Nest components easily with single components, lists, and dictionaries
- JavaScript Bundling - Automatically collects and bundles
.jsfiles from component directories - Type Safety - Pydantic models provide validation and IDE support
Two Ways to Render¶
PyJinHx offers two complementary approaches:
Instantiate components in Python and call .render():
Quick Example¶
from pyjinhx import BaseComponent
class Button(BaseComponent):
id: str
text: str
variant: str = "default"
<!-- button.html (next to button.py) -->
<button id="{{ id }}" class="btn btn-{{ variant }}">
{{ text }}
</button>
button = Button(id="cta", text="Click me", variant="primary")
print(button.render())
# <button id="cta" class="btn btn-primary">Click me</button>
Next Steps¶
- Installation - Install PyJinHx
- Quick Start - Build your first component
- Guide - Learn all the features