Skip to main content

A Django-native component framework with props, state, HTMX, and Alpine.js

Project description

Shrd

A Django-native component framework for building UI with props, server state, slots, and scoped styles — using only the Django ecosystem plus bundled HTMX and Alpine.js.

pip install shrd

📖 Full documentation

Shrd is a framework, not a drop-in library. Your Django project adopts its conventions: components live in your apps, templates sit beside scoped CSS, and HTMX carries server actions.

Philosophy

Shrd does not ship a widget catalog. It gives you a small, familiar model — closer to React/Vue than to Django templates alone — without a build step or SPA complexity:

  • Props — typed inputs declared on a Python class
  • State — server-owned data updated via @action methods
  • Slots — wrap and compose markup like children / default slots
  • Scoped styles — co-located .css files, automatically prefixed to the component
  • Computed — derived values via @computed methods
  • Events — HTMX custom events via @emits and ActionResult
  • HTMX — partial re-renders after actions
  • Alpine.js — optional client-side behavior inside templates
  • View data — optional structured layouts, mutable via ViewTreeComponent

Quick start

# myapp/components.py
from shard import Component, Prop, action

class Card(Component):
    title = Prop(str, default="")
    template_name = "components/card.html"
{% load shard %}
{% shard_scripts %}

{% component Card title="Profile" %}
  <p>Anything here is passed through the default slot.</p>
{% endcomponent %}

See the quickstart guide for a full walkthrough.

Documentation

Topic Link
Installation getting-started/installation
Components concepts/components
Slots concepts/slots
Scoped styles concepts/styles
Actions & HTMX interactivity/actions
HTMX & Alpine guides/htmx-and-alpine
View data guides/view-data
API reference reference/api
Examples examples
Roadmap roadmap
Security security

Example app

pip install shrd[dev]
cd example
python manage.py migrate
python manage.py runserver

Or install from source:

pip install -e ".[dev]"
cd example
python manage.py migrate
python manage.py runserver

Development

pip install -e ".[dev]"
pre-commit install
python -m pytest tests/ -q
python manage.py shard_report   # framework size / page-load weight

96 tests with ≥90% coverage. CI runs pre-commit, Ruff, tests (Python 3.10–3.12), and docs build on every PR.

pre-commit run --all-files  # lint + format locally
pip install -e ".[docs]"
python -m mkdocs serve

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shrd-0.3.1.tar.gz (66.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shrd-0.3.1-py3-none-any.whl (64.3 kB view details)

Uploaded Python 3

File details

Details for the file shrd-0.3.1.tar.gz.

File metadata

  • Download URL: shrd-0.3.1.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shrd-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c7ade134cd6380e32f8736e73035874dee5be8c691675d8a6a805c6f93df5789
MD5 f480718da30fff2d2a79ed1bbfe3d162
BLAKE2b-256 4c3a156565a9df6a205466008d44896179eb72df6281af10f4db2a75a766a799

See more details on using hashes here.

Provenance

The following attestation bundles were made for shrd-0.3.1.tar.gz:

Publisher: workflow.yml on kurtisrogers/Shard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shrd-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: shrd-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 64.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shrd-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97498ebf19f621ee27e277bc913a3992f04b3c60243db61e307e548c002760cd
MD5 9607ec17df0748cc4546d253b22096b9
BLAKE2b-256 be9a8c6ac1402e55d41e8dfb6db125557f38c1f7478ae801796bfec5425306b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for shrd-0.3.1-py3-none-any.whl:

Publisher: workflow.yml on kurtisrogers/Shard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page