Draw.io Core Styles
Master reference for the Draw.io / mxGraph style system.
Covers style string syntax, property categories, color system, fontStyle bitfield,
perimeter matching, and style inheritance.
1. Style String Syntax
Every mxCell carries its appearance in a single style attribute: a semicolon-delimited
string of key=value pairs.
Format Rules
| Rule |
Detail |
| Separator |
Semicolon (;) between every property |
| Pair format |
key=value (camelCase keys, no spaces around =) |
| Leading shape |
A bare word WITHOUT = sets the base shape (e.g., ellipse;) |
| Trailing semicolon |
ALWAYS terminate with ; |
| Booleans |
ALWAYS 0 or 1 — NEVER true / false |
| Colors |
#RRGGBB hex, none (transparent), or default (theme color) |
Leading Shape Identifier
When a style string starts with a bare word (no =), it sets the shape. These two are equivalent:
ellipse;whiteSpace=wrap;html=1;
shape=ellipse;whiteSpace=wrap;html=1;
Common leading identifiers: ellipse, rhombus, triangle, hexagon, swimlane,
image, line, text.
Mandatory Properties
Every AI-generated cell MUST include:
| Property |
Why |
html=1 |
Enables HTML label rendering. Without it, labels lose all formatting. |
whiteSpace=wrap |
Enables word wrapping. Without it, long labels overflow shape bounds. |
2. Property Categories Overview
The style system has 120+ properties across these categories. Full details are in
references/methods.md.
| Category |
Key Properties |
Applies To |
| Fill |
fillColor, gradientColor, opacity, fillOpacity |
Vertices |
| Stroke |
strokeColor, strokeWidth, dashed, dashPattern |
Both |
| Text |
fontSize, fontFamily, fontColor, fontStyle, align |
Both |
| Shape |
shape, perimeter, rounded, arcSize, rotation |
Vertices |
| Edge |
edgeStyle, curved, startArrow, endArrow |
Edges |
| Container |
container, collapsible, startSize, childLayout |
Vertices |
| Behavior |
movable, resizable, editable, deletable |
Both |
Vertex-Only vs Edge-Only Properties
NEVER apply vertex properties to edges or vice versa — they are silently ignored.
- Vertex-only:
fillColor, shape (except connector), container, collapsible, swimlane
- Edge-only:
edgeStyle, startArrow, endArrow, curved, jettySize, exitX/Y, entryX/Y
3. Color System
Valid Color Formats
| Format |
Example |
Use |
#RRGGBB |
#DAE8FC |
Specific hex color |
none |
fillColor=none |
Transparent / no color |
default |
strokeColor=default |
Theme-dependent default |
NEVER use:
- RGB function syntax (
rgb(0,0,0))
- Short hex (
#FFF)
- Named CSS colors (
red, blue) — use #FF0000, #0000FF
Color Properties
| Property |
Applies To |
Default |
fillColor |
Vertex interior |
default (theme white) |
strokeColor |
Border / edge line |
default (theme black) |
fontColor |
Label text |
default (theme black) |
gradientColor |
Gradient end color |
none |
labelBackgroundColor |
Label background |
none |
labelBorderColor |
Label border |
none |
swimlaneFillColor |
Swimlane body fill |
— |
4. fontStyle Bitfield
The fontStyle property uses a bitmask to combine text decorations in a single integer.
Flags
| Flag |
Value |
Effect |
| Bold |
1 |
Bold text |
| Italic |
2 |
Italic text |
| Underline |
4 |
Underlined text |
| Strikethrough |
8 |
Strikethrough text |
Combining Flags
Add flag values together. NEVER use bitwise operators in the style string — use the
pre-computed sum.
| fontStyle |
Result |
0 |
Normal |
1 |
Bold |
2 |
Italic |
3 |
Bold + Italic |
4 |
Underline |
5 |
Bold + Underline |
7 |
Bold + Italic + Underline |
9 |
Bold + Strikethrough |
Decision Tree: fontStyle Value
Need bold?
YES → start with 1
NO → start with 0
Need italic?
YES → add 2
Need underline?
YES → add 4
Need strikethrough?
YES → add 8
Sum = fontStyle value
5. Perimeter System
The perimeter determines WHERE edges connect to a shape's boundary. A mismatched
perimeter causes edges to float away from the shape outline.
Perimeter-Shape Matching (MANDATORY)
| Shape |
REQUIRED Perimeter |
| Rectangle (default) |
rectanglePerimeter (default — omit if rectangle) |
| Rounded rectangle |
rectanglePerimeter |
| Ellipse / Circle |
ellipsePerimeter |
| Double Ellipse |
ellipsePerimeter |
| Rhombus / Diamond |
rhombusPerimeter |
| Triangle |
trianglePerimeter |
| Hexagon |
hexagonPerimeter |
| Cloud |
ellipsePerimeter |
| Cylinder |
rectanglePerimeter |
| Swimlane |
rectanglePerimeter |
| Parallelogram |
rectanglePerimeter |
| Stencil (round) |
ellipsePerimeter |
| Stencil (rectangular) |
rectanglePerimeter |
Decision Tree: Which Perimeter?
Is the shape visually round/oval?
YES → perimeter=ellipsePerimeter
NO →
Is it a diamond/rhombus?
YES → perimeter=rhombusPerimeter
NO →
Is it a triangle?
YES → perimeter=trianglePerimeter
NO →
Is it a hexagon?
YES → perimeter=hexagonPerimeter
NO → perimeter=rectanglePerimeter (or omit — it is the default)
What Happens With Wrong Perimeters
- Ellipse + rectanglePerimeter: Edges connect at bounding box corners instead of
the curved boundary. Visible gaps appear.
- Rectangle + ellipsePerimeter: Edges float outside or inside the rectangle.
- Rhombus + rectanglePerimeter: Edges connect to the bounding box, not the
diamond edges. Gaps appear at the sides.
6. Style Inheritance and Defaults
Resolution Order (later overrides earlier)
- Built-in defaults (hardcoded in mxGraph)
- Theme defaults (from the stylesheet registered in the graph)
- Named style (if the style string references a registered name)
- Inline properties (explicit key=value pairs in the style string)
Vertex Defaults
shape=rectangle;perimeter=rectanglePerimeter;whiteSpace=wrap;html=1;
overflow=hidden;fillColor=#ffffff;strokeColor=#000000;fontColor=#000000;
fontSize=12;fontFamily=Helvetica;align=center;verticalAlign=middle;
Edge Defaults
shape=connector;endArrow=classic;html=1;strokeColor=#000000;fontColor=#000000;
fontSize=12;fontFamily=Helvetica;align=center;verticalAlign=middle;rounded=1;
You only need to specify properties that DIFFER from the defaults. A basic rectangle
needs only whiteSpace=wrap;html=1; because shape and perimeter are already defaults.
7. Quick-Reference Templates
Shapes
// Rectangle
rounded=0;whiteSpace=wrap;html=1;
// Rounded Rectangle
rounded=1;whiteSpace=wrap;html=1;arcSize=10;
// Ellipse
ellipse;whiteSpace=wrap;html=1;perimeter=ellipsePerimeter;
// Diamond
rhombus;whiteSpace=wrap;html=1;perimeter=rhombusPerimeter;
// Triangle
triangle;whiteSpace=wrap;html=1;perimeter=trianglePerimeter;
// Hexagon
shape=hexagon;whiteSpace=wrap;html=1;perimeter=hexagonPerimeter;
// Cylinder (Database)
shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=15;
// Swimlane
swimlane;horizontal=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;container=1;collapsible=0;html=1;whiteSpace=wrap;
Edges
// Standard arrow
endArrow=classic;html=1;
// Orthogonal connector
edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;
// Dashed dependency
endArrow=open;dashed=1;html=1;
// Bidirectional
startArrow=classic;endArrow=classic;html=1;
// No arrows
endArrow=none;startArrow=none;html=1;
// UML inheritance (hollow triangle)
endArrow=block;endFill=0;html=1;edgeStyle=orthogonalEdgeStyle;
// UML composition (filled diamond)
startArrow=diamond;startFill=1;endArrow=open;html=1;
8. Critical Rules Summary
| # |
Rule |
| 1 |
ALWAYS include html=1 in every cell style |
| 2 |
ALWAYS include whiteSpace=wrap for shapes with text labels |
| 3 |
ALWAYS set perimeter matching the shape type (see Section 5) |
| 4 |
ALWAYS terminate style strings with a semicolon |
| 5 |
ALWAYS use 0/1 for booleans — NEVER true/false |
| 6 |
ALWAYS use #RRGGBB hex for colors — NEVER short hex or named colors |
| 7 |
NEVER apply vertex-only properties to edges or vice versa |
| 8 |
ALWAYS set container=1 on shapes that hold children |
| 9 |
ALWAYS set relative="1" on edge mxGeometry elements |
| 10 |
ALWAYS pair labelPosition with opposite align value |
References
- references/methods.md — Complete property reference by category
- references/examples.md — Working XML examples for every style scenario
- references/anti-patterns.md — Common mistakes with explanations and fixes
1---2name: drawio-core-styles3description: Use when styling Draw.io shapes, connectors, or labels. Prevents the common mistake of using wrong property names, missing html=1, or mismatched perimeters that cause rendering failures. Covers style string syntax, property categories, color system, fontStyle bitfield, and perimeter requirements. Keywords: drawio style, fillColor, strokeColor, fontStyle, perimeter, shape style, mxGraph CSS, change color, style shape, bold text, customize appearance, shape doesn't look right.4license: MIT5---67# Draw.io Core Styles89> Master reference for the Draw.io / mxGraph style system.10> Covers style string syntax, property categories, color system, fontStyle bitfield,11> perimeter matching, and style inheritance.1213---1415## 1. Style String Syntax1617Every `mxCell` carries its appearance in a single `style` attribute: a **semicolon-delimited18string** of `key=value` pairs.1920### Format Rules2122| Rule | Detail |23|------|--------|24| Separator | Semicolon (`;`) between every property |25| Pair format | `key=value` (camelCase keys, no spaces around `=`) |26| Leading shape | A bare word WITHOUT `=` sets the base shape (e.g., `ellipse;`) |27| Trailing semicolon | ALWAYS terminate with `;` |28| Booleans | ALWAYS `0` or `1` — NEVER `true` / `false` |29| Colors | `#RRGGBB` hex, `none` (transparent), or `default` (theme color) |3031### Leading Shape Identifier3233When a style string starts with a bare word (no `=`), it sets the shape. These two are equivalent:3435```36ellipse;whiteSpace=wrap;html=1;37shape=ellipse;whiteSpace=wrap;html=1;38```3940Common leading identifiers: `ellipse`, `rhombus`, `triangle`, `hexagon`, `swimlane`,41`image`, `line`, `text`.4243### Mandatory Properties4445Every AI-generated cell MUST include:4647| Property | Why |48|----------|-----|49| `html=1` | Enables HTML label rendering. Without it, labels lose all formatting. |50| `whiteSpace=wrap` | Enables word wrapping. Without it, long labels overflow shape bounds. |5152---5354## 2. Property Categories Overview5556The style system has **120+ properties** across these categories. Full details are in57[references/methods.md](references/methods.md).5859| Category | Key Properties | Applies To |60|----------|---------------|------------|61| **Fill** | `fillColor`, `gradientColor`, `opacity`, `fillOpacity` | Vertices |62| **Stroke** | `strokeColor`, `strokeWidth`, `dashed`, `dashPattern` | Both |63| **Text** | `fontSize`, `fontFamily`, `fontColor`, `fontStyle`, `align` | Both |64| **Shape** | `shape`, `perimeter`, `rounded`, `arcSize`, `rotation` | Vertices |65| **Edge** | `edgeStyle`, `curved`, `startArrow`, `endArrow` | Edges |66| **Container** | `container`, `collapsible`, `startSize`, `childLayout` | Vertices |67| **Behavior** | `movable`, `resizable`, `editable`, `deletable` | Both |6869### Vertex-Only vs Edge-Only Properties7071NEVER apply vertex properties to edges or vice versa — they are silently ignored.7273- **Vertex-only:** `fillColor`, `shape` (except `connector`), `container`, `collapsible`, `swimlane`74- **Edge-only:** `edgeStyle`, `startArrow`, `endArrow`, `curved`, `jettySize`, `exitX/Y`, `entryX/Y`7576---7778## 3. Color System7980### Valid Color Formats8182| Format | Example | Use |83|--------|---------|-----|84| `#RRGGBB` | `#DAE8FC` | Specific hex color |85| `none` | `fillColor=none` | Transparent / no color |86| `default` | `strokeColor=default` | Theme-dependent default |8788NEVER use:89- RGB function syntax (`rgb(0,0,0)`)90- Short hex (`#FFF`)91- Named CSS colors (`red`, `blue`) — use `#FF0000`, `#0000FF`9293### Color Properties9495| Property | Applies To | Default |96|----------|-----------|---------|97| `fillColor` | Vertex interior | `default` (theme white) |98| `strokeColor` | Border / edge line | `default` (theme black) |99| `fontColor` | Label text | `default` (theme black) |100| `gradientColor` | Gradient end color | `none` |101| `labelBackgroundColor` | Label background | `none` |102| `labelBorderColor` | Label border | `none` |103| `swimlaneFillColor` | Swimlane body fill | — |104105---106107## 4. fontStyle Bitfield108109The `fontStyle` property uses a **bitmask** to combine text decorations in a single integer.110111### Flags112113| Flag | Value | Effect |114|------|-------|--------|115| Bold | `1` | **Bold** text |116| Italic | `2` | *Italic* text |117| Underline | `4` | Underlined text |118| Strikethrough | `8` | ~~Strikethrough~~ text |119120### Combining Flags121122Add flag values together. NEVER use bitwise operators in the style string — use the123pre-computed sum.124125| fontStyle | Result |126|-----------|--------|127| `0` | Normal |128| `1` | Bold |129| `2` | Italic |130| `3` | Bold + Italic |131| `4` | Underline |132| `5` | Bold + Underline |133| `7` | Bold + Italic + Underline |134| `9` | Bold + Strikethrough |135136### Decision Tree: fontStyle Value137138```139Need bold?140 YES → start with 1141 NO → start with 0142Need italic?143 YES → add 2144Need underline?145 YES → add 4146Need strikethrough?147 YES → add 8148Sum = fontStyle value149```150151---152153## 5. Perimeter System154155The perimeter determines WHERE edges connect to a shape's boundary. A mismatched156perimeter causes edges to float away from the shape outline.157158### Perimeter-Shape Matching (MANDATORY)159160| Shape | REQUIRED Perimeter |161|-------|-------------------|162| Rectangle (default) | `rectanglePerimeter` (default — omit if rectangle) |163| Rounded rectangle | `rectanglePerimeter` |164| Ellipse / Circle | `ellipsePerimeter` |165| Double Ellipse | `ellipsePerimeter` |166| Rhombus / Diamond | `rhombusPerimeter` |167| Triangle | `trianglePerimeter` |168| Hexagon | `hexagonPerimeter` |169| Cloud | `ellipsePerimeter` |170| Cylinder | `rectanglePerimeter` |171| Swimlane | `rectanglePerimeter` |172| Parallelogram | `rectanglePerimeter` |173| Stencil (round) | `ellipsePerimeter` |174| Stencil (rectangular) | `rectanglePerimeter` |175176### Decision Tree: Which Perimeter?177178```179Is the shape visually round/oval?180 YES → perimeter=ellipsePerimeter181 NO →182 Is it a diamond/rhombus?183 YES → perimeter=rhombusPerimeter184 NO →185 Is it a triangle?186 YES → perimeter=trianglePerimeter187 NO →188 Is it a hexagon?189 YES → perimeter=hexagonPerimeter190 NO → perimeter=rectanglePerimeter (or omit — it is the default)191```192193### What Happens With Wrong Perimeters194195- **Ellipse + rectanglePerimeter:** Edges connect at bounding box corners instead of196 the curved boundary. Visible gaps appear.197- **Rectangle + ellipsePerimeter:** Edges float outside or inside the rectangle.198- **Rhombus + rectanglePerimeter:** Edges connect to the bounding box, not the199 diamond edges. Gaps appear at the sides.200201---202203## 6. Style Inheritance and Defaults204205### Resolution Order (later overrides earlier)2062071. **Built-in defaults** (hardcoded in mxGraph)2082. **Theme defaults** (from the stylesheet registered in the graph)2093. **Named style** (if the style string references a registered name)2104. **Inline properties** (explicit key=value pairs in the style string)211212### Vertex Defaults213214```215shape=rectangle;perimeter=rectanglePerimeter;whiteSpace=wrap;html=1;216overflow=hidden;fillColor=#ffffff;strokeColor=#000000;fontColor=#000000;217fontSize=12;fontFamily=Helvetica;align=center;verticalAlign=middle;218```219220### Edge Defaults221222```223shape=connector;endArrow=classic;html=1;strokeColor=#000000;fontColor=#000000;224fontSize=12;fontFamily=Helvetica;align=center;verticalAlign=middle;rounded=1;225```226227You only need to specify properties that DIFFER from the defaults. A basic rectangle228needs only `whiteSpace=wrap;html=1;` because shape and perimeter are already defaults.229230---231232## 7. Quick-Reference Templates233234### Shapes235236```237// Rectangle238rounded=0;whiteSpace=wrap;html=1;239240// Rounded Rectangle241rounded=1;whiteSpace=wrap;html=1;arcSize=10;242243// Ellipse244ellipse;whiteSpace=wrap;html=1;perimeter=ellipsePerimeter;245246// Diamond247rhombus;whiteSpace=wrap;html=1;perimeter=rhombusPerimeter;248249// Triangle250triangle;whiteSpace=wrap;html=1;perimeter=trianglePerimeter;251252// Hexagon253shape=hexagon;whiteSpace=wrap;html=1;perimeter=hexagonPerimeter;254255// Cylinder (Database)256shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;size=15;257258// Swimlane259swimlane;horizontal=1;startSize=30;fillColor=#f5f5f5;strokeColor=#666666;fontStyle=1;container=1;collapsible=0;html=1;whiteSpace=wrap;260```261262### Edges263264```265// Standard arrow266endArrow=classic;html=1;267268// Orthogonal connector269edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=classic;270271// Dashed dependency272endArrow=open;dashed=1;html=1;273274// Bidirectional275startArrow=classic;endArrow=classic;html=1;276277// No arrows278endArrow=none;startArrow=none;html=1;279280// UML inheritance (hollow triangle)281endArrow=block;endFill=0;html=1;edgeStyle=orthogonalEdgeStyle;282283// UML composition (filled diamond)284startArrow=diamond;startFill=1;endArrow=open;html=1;285```286287---288289## 8. Critical Rules Summary290291| # | Rule |292|---|------|293| 1 | ALWAYS include `html=1` in every cell style |294| 2 | ALWAYS include `whiteSpace=wrap` for shapes with text labels |295| 3 | ALWAYS set perimeter matching the shape type (see Section 5) |296| 4 | ALWAYS terminate style strings with a semicolon |297| 5 | ALWAYS use `0`/`1` for booleans — NEVER `true`/`false` |298| 6 | ALWAYS use `#RRGGBB` hex for colors — NEVER short hex or named colors |299| 7 | NEVER apply vertex-only properties to edges or vice versa |300| 8 | ALWAYS set `container=1` on shapes that hold children |301| 9 | ALWAYS set `relative="1"` on edge `mxGeometry` elements |302| 10 | ALWAYS pair `labelPosition` with opposite `align` value |303304---305306## References307308- [references/methods.md](references/methods.md) — Complete property reference by category309- [references/examples.md](references/examples.md) — Working XML examples for every style scenario310- [references/anti-patterns.md](references/anti-patterns.md) — Common mistakes with explanations and fixes