Components
Subclass htmforge.Component and declare typed props as Pydantic fields.
- Implement
render() -> Elementand return the rootElement. validate_assignment=Trueensures runtime prop assignment is validated.- Use
to_html()to get the rendered HTML string.
htmx_attrs() returns only set HTMX props; dicts are compact JSON-serialized.
__init_subclass__ guard raises TypeError if render is missing at instantiation.
Example button using htmx props: