django-cotton
A library for creating reusable UI components in Django using a modern, tag-based syntax.
Workflow: Creating a cotton component
Create a new HTML file within your app’s
templates/cotton/directory (e.g.,card.html).Define the outer wrapper and use
{{ attrs }}to ensure standard HTML attributes likeclassoridpass through.Place the
{{ slot }}variable inside the wrapper to define where nested content will be rendered.Add specific variables (e.g.,
{{ title }}) for data that should be passed as attributes.Call the component in your view template using the
<c-prefix followed by the filename (e.g.,<c-card title="Hello">World</c-card>).
Workflow: Adding SVG to template
Prompt an LLM to generate the SVG code for a specific icon or shape. Use google-ai-mode-create-svg.md
Create the component file
templates/cotton/svg/icon-name.html.Paste the SVG code into the file.
Reference the icon in your templates using the
<c-svg.icon-name />syntax.