Skip to main content

django-cotton-uswds

USWDS components as Django Cotton templates.

Use the U.S. Web Design System in your Django projects with a clean, declarative component syntax.

Installation

git clone https://github.com/iversondiles/django-cotton-uswds.git
cd django-cotton-uswds
pip install -e .

Then add both django_cotton and django_cotton_uswds to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "django_cotton",
    "django_cotton_uswds",
]

Usage

Components follow the <c-component> naming convention:

<c-alert type="info" heading="Informative status">
    This is an informative alert.
</c-alert>

Attributes pass through to the underlying USWDS markup, so you can use the same options documented on the USWDS component pages.

USWDS Assets

This package provides markup only — no CSS or JavaScript is bundled. You need to add USWDS assets to your project separately.

See the USWDS getting started guide for instructions on compiling and including the USWDS stylesheet and scripts.

Available Components

This project is in early development. Components are being added incrementally. See the USWDS components page for reference on what's planned.

Form Rendering

The package includes a USWDS form renderer that automatically styles Django forms with USWDS markup — labels, hints, error messages, and all standard widget types.

Per-form via mixin

from django import forms
from django_cotton_uswds.mixins import USWDSFormMixin

class ContactForm(USWDSFormMixin, forms.Form):
    name = forms.CharField(label="Full name")
    email = forms.EmailField()
    message = forms.CharField(widget=forms.Textarea)

Globally via settings

# settings.py
FORM_RENDERER = "django_cotton_uswds.renderer.USWDSFormRenderer"

Widget attribute passthrough

USWDS-specific attributes can be passed through widget attrs:

class MyForm(USWDSFormMixin, forms.Form):
    name = forms.CharField(
        widget=forms.TextInput(attrs={"width": "md"}),
    )
    resume = forms.FileField(
        widget=forms.ClearableFileInput(attrs={"accept": ".pdf,.doc"}),
    )

Supported widget mappings

Django widget USWDS rendering
TextInput, EmailInput, NumberInput, etc. usa-input text field
Textarea usa-textarea
Select usa-select dropdown
RadioSelect Fieldset with usa-radio buttons
CheckboxSelectMultiple Fieldset with usa-checkbox items
CheckboxInput (boolean) Single usa-checkbox
ClearableFileInput usa-file-input

MCP server

An optional MCP server exposes component docs and a form scaffolder to AI assistants. Install with the mcp extra and point your MCP client at django-cotton-uswds-mcp:

pip install "django-cotton-uswds[mcp]"

See django_cotton_uswds/mcp/README.md for client configuration and tool details.

Demo

A demo project is included to showcase components. Requires just and uv.

# Install the package with demo dependencies
just install

# Run the development server at http://127.0.0.1:8000/
just demo

# Build a static site into demo_project/dist/
just build

Requirements

  • Python 3.10+
  • Django 4.2+
  • django-cotton 1.2.1+

Domain Language

See UBIQUITOUS_LANGUAGE.md for a glossary of canonical domain terms used in this project.

License

MIT

Metadata

Release files for django-cotton-uswds 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cotton-uswds 1.3.1
File Size Uploaded Provenance Actions
django_cotton_uswds-1.3.1.tar.gz 216.9 kB With provenance Details for django_cotton_uswds-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-cotton-uswds 1.3.1
File Interpreter ABI Platform Actions
django_cotton_uswds-1.3.1-py3-none-any.whl Python 3 none any Details for django_cotton_uswds-1.3.1-py3-none-any.whl

Total release size: 397.3 kB

Release files / django_cotton_uswds-1.3.1.tar.gz

Download URL django_cotton_uswds-1.3.1.tar.gz
Size 216.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3f8c29faba851bfca0be6d47964a06232bd1271ea8c8851543916e1aa52e9f36
BLAKE2b-256 checksum
How to use checksums
cb0b1f73ddb9243fc0e3f0dd1220df3469501ff3fd58904250c23ea80f653842
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / django_cotton_uswds-1.3.1-py3-none-any.whl

Download URL django_cotton_uswds-1.3.1-py3-none-any.whl
Size 180.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd797762f8294a4ff814ca3259e42f28845d9be3a1b56376ece3f2ec1f33fd5c
BLAKE2b-256 checksum
How to use checksums
ad586e2b394a0cc45d73f5ad6938cdc94a93bf1557fabf4b3803d02b157c4e20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Security for django-cotton-uswds 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_cotton_uswds-1.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page