daisy-cotton
Base daisyUI-styled django-cotton components: buttons, inputs, cards, alerts and the rest of an application's furniture
Built on daisyUI and django-cotton. A project that wants daisyUI-styled Cotton components depends on this package directly: install it, add it to INSTALLED_APPS, and each <c-name> tag is ready to use. It carries no settings, no menus, no icon registry and no views of its own — see Scope & philosophy.
Status
Pre-1.0: names, attributes and the set of classes a component emits can change between minor versions. The CHANGELOG is how a project finds out what has landed.
Eighty-three components are built so far: accordion, alert, avatar, badge, breadcrumbs, button, card, carousel, chat, collapse, countdown, diff, divider, dock, drawer, dropdown, fab, footer, form.calendar, form.checkbox, form.fieldset, form.file-input, form.filter, form.input, form.label, form.otp, form.radio, form.range, form.rating, form.select, form.textarea, form.toggle, hero, hover-3d, hover-gallery, icon, indicator, join, kbd, link, list, loading, mask, megamenu, menu, modal, navbar, progress, radial-progress, skeleton, stack, stat, status, steps, swap, table, tabs, text-rotate, timeline, toast, tooltip and mockup.*. Pagination has no component: daisyUI builds it from join and btn and gives it no class of its own, so write it with those two. Aura has no component either: it only decorates another element, so wrap the component to highlight in a <div class="aura"> with daisyUI's style and size classes. Each one is documented live in the component gallery (python manage.py runserver from a checkout). More land as the need arises.
<c-icon> renders name as a literal CSS class string and resolves nothing itself — a project wanting name-based icon resolution provides its own override (see docs/adr/0001).
<c-alert> takes variant (info, success, warning, error), soft/outline/dash for style, and horizontal/vertical for direction, each accepting a breakpoint such as sm; a caller-given role replaces the default role="alert", so role="status" gives a polite announcement instead of an interruption. icon draws an icon before the message, as it does on <c-button>, and an alert with no icon has none: variant sets the colour only. The icon and the dismiss button are drawn by <c-icon> and <c-button>; the dismiss button's accessible name is the translatable "Dismiss" with its glyph hidden from assistive technology. dismissible and delay need Alpine.js on the page — this package doesn't ship or load it. Without Alpine, the alert still renders and reads fine, but the dismiss button does nothing and delay never fires.
<c-toast> pins its content to a corner or edge of the screen and has no role or live region of its own, so put alerts inside it and each keeps its own. A project rendering Django's messages framework writes:
<c-toast placement="top end">
{% for message in messages %}
<c-alert variant="{{ message.level_tag }}" dismissible>{{ message }}</c-alert>
{% endfor %}
</c-toast>
Django's debug level tag has no matching alert colour, so a debug message falls back to the plain alert. The same goes for any level tag a project adds through MESSAGE_TAGS. An alert knows nothing about message levels, so a project that wants an icon per level, or only certain levels shown, writes its own component around <c-alert> and makes those choices there.
<c-menu> is filled with <c-menu.item>, <c-menu.title>, <c-menu.submenu> and <c-menu.divider>. The divider draws a line between groups of entries, so a menu built from components needs no hand-written list item for it:
<c-menu>
<c-menu.item href="/profile/" text="Profile" />
<c-menu.item href="/settings/" text="Settings" />
<c-menu.divider />
<c-menu.item text="Sign out" type="submit" form="sign-out" />
</c-menu>
Requirements
- Python 3.12+
- Django 5.2, 6.0 or 6.1
- django-cotton 2.6+
- daisyUI 5.7 or later, loaded by the project
daisyUI is a hard requirement and this package does not ship it. Any project already running daisyUI 5.7 or later satisfies it, through whatever Tailwind build the project already has. The menu's paged attribute writes the class menu-paged, which daisyUI added in 5.7.0, so on an earlier release a paged menu comes out unstyled.
Install
pip install daisy-cotton
Add it to INSTALLED_APPS:
INSTALLED_APPS = [
...,
"django_cotton",
"daisy_cotton",
]
Usage
Each component is a Cotton tag named after its daisyUI component, configured through attributes that use daisyUI's own modifier names:
<c-card title="Storage" border>
Almost full.
<c-slot name="actions">
<c-button variant="primary" size="sm" text="Upgrade" />
</c-slot>
</c-card>
Classes passed with class are added to the component's own, and any other attribute passes through to its root element.
Listing the components a project can use
cotton_components lists every Cotton component the project can render, from its own template folders and from every installed package, so a developer finds the one that already does the job before writing another.
$ python manage.py cotton_components card
<c-card> daisy_cotton daisyUI's card: an optional figure, a body and an optional title and actions row.
1 component
Each line gives the tag to write, as a template writes it (with COTTON_SNAKE_CASED_NAMES on, its default, radial_progress.html is <c-radial-progress>), the package it comes from (an app label, or project for a project-level template folder) and the first sentence of its @description, or — when there is none. A component that more than one folder provides is listed once, as the copy Django's template loaders find first, and its line ends with (overrides <package>), naming the packages whose copies it hides.
| Option | Effect |
|---|---|
term |
Keep components whose name contains it, ignoring case. A hyphen matches an underscore. |
--text WORDS |
Keep components whose description contains the words, ignoring case. |
--package LABEL |
Keep one package's components. |
--show NAME |
Print one component's documentation instead of the list. It ignores the term and the filters. |
--json |
Print a JSON array of name, tag, package, path, summary and overrides. With --show, print one object. |
Every option combines with the others. A term that matches nothing prints a message and exits successfully. Files and folders that start with _, and files that no tag can reach (a - in the path while names are snake-cased, or a . in a file name), are not listed. The command follows the project's COTTON_DIR setting. With django-cotton 2.9 or later it also lists the components in cotton/ that django-cotton falls back to when the configured folder has none of that name, and a copy in the configured folder overrides the cotton/ one.
Read one component's documentation
Run python manage.py cotton_components --show card to learn how to use a component without opening its file. It prints the tag, the file that renders, the package, the packages whose copies it overrides, the full description, every prop and every slot, and whether the component passes extra attributes to its element. It never prints the template body.
$ python manage.py cotton_components --show menu.title
<c-menu.title>
File: /…/daisy_cotton/templates/cotton/menu/title.html
Package: daisy_cotton
No template uses it (dynamic <c-component is="…"> references are not counted)
A heading row inside a menu, used inside menu. It is not interactive. Attributes other than the ones below land on the list item.
Props:
text text — The heading.
class text — Extra classes added to the list item.
Slots:
(default) — Extra content shown after the text.
Passes extra attributes to its element.
A prop line gives its name, type, options, default and description, then required, deprecated: <message> or hidden when the annotation sets them. A slot line gives its name, or (default), its description and its example content. A component with no annotations shows — for its description, Props: none and Slots: none.
The count is the number of template files, in every folder the project loads templates from, that write <c-name or {% cotton name %}. Templates inside a COTTON_DIR folder or the cotton/ fallback, so other components, are not counted, and neither are dynamic <c-component is="…"> references. A name that matches no component stops with an error that names it and lists up to five of the closest names. --show NAME --json prints one object with name, tag, package, path, summary, overrides, description, props, slots, accepts_attrs, uses and use_paths. summary and description are null when there is no description.
The same list is available from Python. ComponentCatalog().search("card") returns Component records in name order, each with name, tag, package, path, overrides and summary. search also takes text= and package=, and components() returns every component. get("menu.title") returns one component, or raises ComponentNotFound, whose name and suggestions say what was asked and which names are close. uses(component) returns the paths of the page templates that use it, and component.documentation holds its parsed props, slots and description.
Calendar
<c-form.calendar> writes Cally's <calendar-date> element, or <calendar-range> with range, carrying daisyUI's cally class. It shows nothing until the project loads Cally, and this package does not. Add the module script to the page's head, pinning the version you have tested or hosting the file yourself:
<script type="module" src="https://unpkg.com/cally@0.9.2"></script>
Cally's own attributes (value, min, max, locale, first-day-of-week) go on the tag and reach the calendar unchanged, months="2" shows two months side by side, and class is added to the calendar's own. The previous and next buttons hold an icon drawn by <c-icon> and a visually hidden name, so pass icon classes through previous_icon and next_icon unless your project's <c-icon> resolves names:
<c-form.calendar id="delivery-calendar" min="2026-09-01" previous_icon="bi bi-chevron-left" next_icon="bi bi-chevron-right" />
<input type="hidden" name="delivery_date" id="delivery-date">
Cally does not write to a form itself. Its change event carries the chosen date in the calendar's value, so a few lines of script copy it into the hidden input:
<script>
document.getElementById("delivery-calendar").addEventListener("change", (event) => {
document.getElementById("delivery-date").value = event.target.value;
});
</script>
For a range the same value is the two dates joined with a slash, such as 2026-09-01/2026-09-07.
Scope & philosophy
What this is. One Cotton component for each base daisyUI component, and nothing else. One exception: the cotton_components management command, which lists every Cotton component a project can render, from any package. A component that daisyUI builds out of other components, or a class that only modifies another component, gets no Cotton component of its own. The validator is one such class: add it to a control through its class, or to the OTP's input through input_class. Everything here is presentation: templates configured through attributes and themed by whatever daisyUI theme the project runs.
What this deliberately is not.
- Not an application shell. No settings, no menu system, no icon registry, no views.
- Not page-level layout. The
herocontainer ships, but composed hero sections (the heading, copy and calls to action inside it) and other page sections stay with the project, built from these components. - Not a CSS framework. daisyUI, its themes and Tailwind's preflight come from the project.
- Not a JavaScript layer. The package ships no scripts. A project that wants behaviour daisyUI's CSS doesn't give, such as smarter dropdown placement, adds it by overriding the component. The calendar is the one component that needs a script to show anything: it is drawn by Cally, which the project loads itself (see Calendar). The modal's close button and backdrop each carry a one-line
onclickthat calls the dialog's ownclose(), which keeps them working inside a form. A project whose Content Security Policy blocks inline handlers overrides the modal. - Not coupled to Django objects. Components take plain values. Wiring one up to a form, a paginator or the messages framework is the project's job.
- Not shaped for any particular project. Nothing here exists because one adopter needed it.
Tie-breaks. When two of these pull against each other:
- Following daisyUI beats convenience. A component's attributes use daisyUI's own names for its modifiers rather than a friendlier parallel vocabulary.
- Leaving it to the project beats doing it here. If only some adopters need it, they get it by overriding the component.
- Fewer attributes beat more. Anything a component doesn't need to decide passes straight through to the markup.
Prior art
labbhq/labb is an actively maintained django-cotton + daisyUI 5 component library covering similar ground. It is a batteries-included framework — its own CLI, reactivity layer, icon system and project scaffolder — rather than a thin base layer, and daisy-cotton's purpose here is narrower: a dependency-free set of base primitives a project drops in alongside its own choices. See docs/contributing/brainstorm.md for the fuller reasoning.
Contributing
To set up a checkout, open the component gallery, run the checks or add a component, see CONTRIBUTING.
Changelog
See CHANGELOG.md.
License
MIT. See LICENSE.
Metadata
Release files for daisy-cotton 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| daisy_cotton-0.2.1.tar.gz | 60.5 kB | With provenance | Details for daisy_cotton-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| daisy_cotton-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for daisy_cotton-0.2.1-py3-none-any.whl |
Total release size: 162.8 kB
Release files / daisy_cotton-0.2.1.tar.gz
| Download URL | daisy_cotton-0.2.1.tar.gz |
|---|---|
| Size | 60.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f64a1b23f91efd38d6ff7ed1a6f7381faa18dd130967d76bf18445b89e8461a7
|
|
BLAKE2b-256 checksum How to use checksums |
2c8068ca8b48aad333d7b6d7f144e587f70d13ba46458bef0550e10beef6ea0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 26, 2026.
Transparency logRelease files / daisy_cotton-0.2.1-py3-none-any.whl
| Download URL | daisy_cotton-0.2.1-py3-none-any.whl |
|---|---|
| Size | 102.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f50408ca36627288256294dfc92452b33d998e48fe8e58dbdeb304464f55a7ff
|
|
BLAKE2b-256 checksum How to use checksums |
53535a6784c2ac9f18e13e4784753b403a9f1d077c408f87e308d3e93c2ef622
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 26, 2026.
Transparency logSecurity for daisy-cotton 0.2.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
Both files in this release have been uploaded with provenance metadata.
Attestation for daisy_cotton-0.2.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 Nov 26, 2026.
Transparency logA 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.