Skip to main content

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

Project description

Shard

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.

📖 Full documentation

Shard 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

Shard 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

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.0.tar.gz (62.3 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.0-py3-none-any.whl (60.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shrd-0.3.0.tar.gz
  • Upload date:
  • Size: 62.3 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.0.tar.gz
Algorithm Hash digest
SHA256 9f4256cb6d0211b002aa95a9946227501de5bdb112473aff9263e0919522af27
MD5 984c83b6d91eaf8d6e426e24af293879
BLAKE2b-256 55d0c1b7954e4117497d6c3612f3d2c9913ef0ee6bce50cd0b6d7ad1035142cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for shrd-0.3.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: shrd-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 60.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 880c00f51e62b56a89173ddadb63e25ce5f76abb2aa65b1249ecf121d57df6ba
MD5 61370a60cb110ef151a6b13b362a96f3
BLAKE2b-256 dea895183ef7c4810c5f7f3118e988f7e8f10a29f6e45398cd7388df9eea77db

See more details on using hashes here.

Provenance

The following attestation bundles were made for shrd-0.3.0-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