SVG conventions
The structure of an icon source file: the root, the role groups, what is allowed, and what the lint rejects.
Last updated
An icon source file is tooling/generator/icons/<name>.svg. It is the authoritative input: everything else (the SVG files, the packages, the website) is generated from it and is never edited by hand.
A source file must be valid SVG, self-contained, free of editor leftovers, and easy for the next person to edit.
A complete example
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256"
data-category="Interface" data-tags="notification,alert,reminder,ring">
<g data-role="area" fill="currentColor" opacity="0.2">
<path d="M56 104 A72 72 0 0 1 200 104 V144 L216 184 H40 L56 144 Z"/>
</g>
<g data-role="line" fill="none" stroke="currentColor" stroke-width="16"
stroke-linecap="round" stroke-linejoin="round">
<path d="M56 104 A72 72 0 0 1 200 104 V144 L216 184 H40 L56 144 Z"/>
<path d="M104 208 H152"/>
</g>
</svg>
The root
xmlnsis present.viewBox="0 0 256 256". [lint root]width="256" height="256"are kept, and if present must be 256: editors and file previews that ignore the viewBox then show the file at the right size.data-categoryanddata-tags: see Metadata.- Optional switches, each a deliberate decision:
data-fill="outline"(the fill weight stays outlined),data-size="symbol"(a small mark),data-detail="reviewed"(more than eight strokes, checked at 16 px),data-badge="custom"(the modifier is drawn into the icon).
No other attributes on the root.
Groups and roles
Every shape is inside a <g data-role="...">. [lint role] The roles are line, detail, area, hole, dot, dotcut, and for variants slash and badge. What each becomes in the six weights is in Weights and roles.
Presentation is set on the group, not on each shape:
| Role | Presentation on the group |
|---|---|
line, detail, slash, badge |
fill="none" stroke="currentColor" stroke-width="16" stroke-linecap="round" stroke-linejoin="round" [lint stroke] |
area |
fill="currentColor" opacity="0.2" |
hole |
fill="none" |
dot, dotcut |
fill="currentColor" |
Shapes
Use plain SVG shapes: path, circle, ellipse, rect, line, polyline, polygon. Draw with the fewest points that make a clean shape and keep separate shapes separate: the build flattens them per weight, so merging them yourself only makes the source harder to edit. Whole numbers for line ends, circle centres and rectangle corners. [lint off-grid]
What is not allowed
These fail the lint. [lint svg-safe]
- Scripts and event handler attributes (
onclickand the like). - Raster images, embedded fonts, foreign content.
- Filters, gradients, patterns, masks, clip paths, embedded styles and
defs. id,class,styleandtransformattributes, andhref.- Links or references to anything outside the file.
- Text elements.
Reasons: ids and styles leak between icons when SVGs are put into one page; a transform scales a stroke along with the shape and breaks the 16-unit rule; and anything external or active has no place in an icon that is embedded in other people’s pages.
Also keep out empty groups, empty paths, unused attributes and editor metadata (Figma, Illustrator, Inkscape and Affinity all add some).
Colors
currentColor only. No hex colors, no theme colors. The icon takes the color of the text around it.
Optimising
The build outlines and compresses everything for you, so the source stays readable. Optimise by hand only to remove noise. Never run a lossy tool over a source file: it can change coordinates the lint wants whole, merge shapes the roles keep apart, or rewrite strokes as filled paths.
Source or generated?
| Where | What | Edit it? |
|---|---|---|
tooling/generator/icons/*.svg |
the source | yes |
tooling/generator/build/, svg/ |
outlined data and per-weight files | no, generated |
packages/* |
the platform packages | no, generated, committed at release |
Validation
uv run scripts/icon.py check <name>
runs the lint (every rule in the lint rules reference) and the consistency audit for the icon. Then look at it: icon.py weights <name>.