Full IntelliSense, validation, and tooling for Django Cotton components in VS Code β autocomplete, hover docs, 19 diagnostic rules, quick fixes, and a component explorer. Stop guessing prop names and catch template mistakes before they hit the runtime.
Autocomplete every component, navigate, and accept β without leaving the keyboard
Hover any tag for its full prop documentation
Catch mistakes as you type β 19 diagnostic rules
Select any component to inspect its props, slots, and highlighted source β in the sidebar
- Install β search Cotton Props in the Extensions view, or run
ext install velezanthony.cotton-props. - Requirements β a Django Cotton project with component templates, and VS Code 1.97+. The default
templates/cotton/layout needs zero configuration. - Go β open any
.htmlordjango-htmltemplate, type<c-, and autocomplete, hover docs, and diagnostics light up instantly.
Everything works in .html and django-html files, live as you type.
| β‘ Autocomplete | tags, props, and values β grouped by category, with type / default / required / deprecated badges |
| π‘ Hover docs | description, prop table, slots, and trigger HTML on any tag or prop |
| π§ Navigation | Go to Definition (F12), Find All References, Outline symbols, Rename Prop (F2) |
| π Dynamic dispatch | understands <c-component is="..."> in all three forms |
| π¦ Diagnostics | 19 edit-time rules across component and usage files |
| π οΈ Quick fixes | one-click document / sync / insert actions on the 9 auto-repairable diagnostics |
| π Auto-rename tag | the closing tag follows the opening tag as you edit, through nesting |
| ποΈ Sidebar explorer | component tree, detail panel, and drag-and-drop usage blocks |
| π Refactors | Wrap with Component, Extract to Component, convert direct β dispatch |
| π¨ Editor aids | semantic highlighting, inlay hints, code lens, folding, signature help, status-bar count |
| π Safe renames | renaming a component file updates every <c-tag> reference project-wide |
π¦ All 19 diagnostic rules β what gets flagged at edit time
In component files:
- Duplicate
@propdefinitions @propmissing from<c-vars>(shows default value if defined)- Undocumented props in
<c-vars> - Unused props (defined but never referenced in template body)
- Default mismatch β
@propand<c-vars>have different default values @propdefines default but<c-vars>attr has no value (bare attr)<c-vars>has default value but@propdoesn't document one| requiredco-exists with| default:(parser silently dropsrequired)- Type-default mismatch β
:booleandefault outsideTrue/False/1/0, or:numberdefault that won't parse - Enum default out of range β
:selectdefault (or<c-vars>value) not in the option list - Dynamic-prefix mismatch β
:fooin@propvsfooin<c-vars>(or vice versa) - Missing
<c-vars>β@propdeclared but no<c-vars>tag (Cotton passes nothing to the template) - Missing prop description β
@propwithout| description:filter (hint-level)
In usage files:
- Component not found
- Unknown prop (
@strictmode) - Duplicate prop on same tag
- Deprecated prop usage (strikethrough hint)
- Invalid type value (select, boolean, number)
- Missing required prop
- Invalid component name β a tag like
<c-...>that could never name any component <c-component>with nois(or:is) attribute
[!NOTE] Unused components are flagged in the sidebar (badge
Uon the tree item), not as a file diagnostic β "this component isn't referenced anywhere" is metadata about its place in the system, not a code error. Add{# @ignore-unused #}inside the component file to suppress it for library or dynamic-tag components.
[!TIP] Type validation is smart-skipped for dynamic props (
:collapsed="variable") and template expressions ({{ var }},{% tag %}) β those are Django values, not literals, so there are no false positives.<c-atoms.badge variant="oops" /> <!-- Error: invalid select value --> <c-atoms.badge :variant="user_variant" /> <!-- skipped: Django variable -->
π οΈ Every quick fix β one click on the lightbulb
- Document prop / Document all props β generate
@propannotations with guessed types - Add required prop / Add all required props β insert missing required props with defaults
- Add to
<c-vars>/ Add all missing β insert missing props in the right format (:dynamic,boolean=False,text="value") - Sync
<c-vars>default β update a bare or mismatched value to match the@propdefault - Remove
| required/ Remove| default:β resolve a required-with-default conflict - Replace with
<option>β one action per allowed:selectoption when a value is out of range - Add / Remove
:prefix β toggle the dynamic prefix on a<c-vars>attr to match its@prop - Add
<c-vars />tag β insert the missing declaration when@prophas no<c-vars>sibling - Add
| description:""filter β fill in a missing description
π Dynamic tag dispatch β the three forms of <c-component is="...">
Cotton's built-in dispatcher renders a component whose name is decided at runtime. The extension understands all three shapes:
| Syntax | Treatment |
|---|---|
<c-component is="icons.spinner" /> |
Direct reference to c-icons.spinner β full Go-to-Definition, hover, completion, references. Emits component-not-found if it doesn't resolve. |
<c-component is="icons.{{ name }}" /> |
The static head is a prefix match: every component under c-icons.* counts as referenced (no false unused badge). |
<c-component :is="my_var" /> |
Pure Django expression β unresolvable. Use {# @ignore-unused #} on the target if needed. |
Multi-line declarations work the same way. Renaming a component file rewrites every is="literal-target" pointing at it, and a refactor action converts between the direct and dispatch forms.
ποΈ Sidebar explorer β tree, badges, detail panel, drag & drop
The activity-bar icon opens the Cotton Components panel:
- Components tree β collapsible categories with aggregated diagnostic counts:
atoms 59 Β· 4E 2W 8H Β· 12 unused - Per-component badges β a single count for the highest severity present (capped at
9+), coloured by that severity; aUbadge when a component has no diagnostics and is referenced nowhere. The row text spells the full breakdown out:3 props Β· 2E 1W 8H Β· unused - Detail panel β click a component for its props table, slots, and syntax-highlighted source
- Drag & drop β drag a component into the editor to insert a full usage block with every prop as a tabstop and defaults pre-filled;
Tabsteps through them - Tag filter β the title-bar button opens a filter box and the tree narrows as you type, matching a case-insensitive substring against the full dotted tag (so both
atomsandbuttonreachatoms.button). The active filter shows asFilter: β¦in the view header and survives closing the box; clear it with the title-bar button, by emptying the box, or withEscapewhile the tree has focus - Copy tag and in-tree search (
Ctrl+F)
π¨ Semantic highlighting β @prop annotation colors (theme-aware)
| Token | Example | Color |
|---|---|---|
| Delimiters | {# #} | |
comment (green/gray) |
| Keywords | @prop |
keyword (purple) |
| Prop name | variant |
variable (blue) |
| Filter names | default description |
variable (blue) |
| Values | "primary" 13 False |
string (orange) |
| Component tags | c-atoms.button |
keyword (purple) |
Colors adapt to your active VS Code theme.
The full catalogue lives in docs/REFERENCE.md:
- Prop annotation syntax β every
@propfilter, the<c-vars>contract, and how the two stay in sync - Diagnostic rules β one section per code, with the smallest input that triggers it
- Settings β every
djangoCottonProps.*option
Components not showing up?
- No completions, or the sidebar is empty? The extension scans
templates/cotton/by default. If your components live elsewhere, add the folder todjangoCottonProps.templatePathsβ path suffixes matched at any depth, so one entry covers the project root and every Django app. Changes apply live, no reload. - A component is flagged
unusedbut it isn't? It's reached only through a dynamic<c-component is="...">the indexer can't resolve. Add{# @ignore-unused #}inside the component file to clear the badge. - A usage isn't validated? Type checks are skipped on purpose for dynamic props (
:prop="var") and template expressions ({{ }},{% %}) β those are Django values, not literals.
Built for Django Cotton Β· MIT licensed Β· Requires VS Code 1.97+



