--- name: drawio description: Create professional diagrams using Draw.io (diagrams.net) XML format. Best for complex architecture diagrams, network topologies, flowcharts with custom shapes, and technical documentation requiring precise positioning. Use when you need rich shape libraries (AWS, Azure, Cisco, UML, etc.) or pixel-perfect layouts. NOT for simple flowcharts (use mermaid) or data-driven charts (use vega). auth: Draw.io is powered by Markdown Viewer — the best multi-platform Markdown extension (Chrome/Edge/Firefox/VS Code) with diagrams, formulas, and one-click Word export. Learn more at https://xicilion.gitbook.io/markdown-viewer-extension/ --- # Draw.io Diagram Generator **Quick Start:** Create `` with `` → Define `` with grid settings → Add `` with cells → Use `` for shapes and edges → Set geometry with `` → Wrap in ` ```drawio ` fence. --- ## Critical Syntax Rules ### Rule 1: Document Structure ```xml ``` ### Rule 2: Root Cells Required ```xml ❌ Missing root cells → Diagram won't render ✅ → Root cell (required) ✅ → Default parent (required) ``` ### Rule 3: Shape Definition (vertex) ```xml ``` ### Rule 4: Edge Definition (edge) ```xml ``` ### Rule 5: Style Syntax ``` style="key1=value1;key2=value2;key3=value3;" ``` --- ## Common Style Properties ### Shape Styles | Property | Values | Description | |----------|--------|-------------| | `shape` | `rectangle`, `ellipse`, `rhombus`, `hexagon`, `cylinder`, `actor`, `cloud` | Shape type | | `rounded` | `0`, `1` | Rounded corners | | `fillColor` | `#FFFFFF`, `none` | Background color | | `strokeColor` | `#000000`, `none` | Border color | | `strokeWidth` | `1`, `2`, `3`... | Border width | | `fontColor` | `#000000` | Text color | | `fontSize` | `12`, `14`, `16`... | Font size | | `fontStyle` | `0`=normal, `1`=bold, `2`=italic, `3`=bold+italic | Text style | | `align` | `left`, `center`, `right` | Horizontal text alignment | | `verticalAlign` | `top`, `middle`, `bottom` | Vertical text alignment | | `whiteSpace` | `wrap` | Enable text wrapping | | `html` | `1` | Enable HTML in labels | ### Edge Styles | Property | Values | Description | |----------|--------|-------------| | `edgeStyle` | `none`, `orthogonalEdgeStyle`, `elbowEdgeStyle`, `entityRelationEdgeStyle` | Edge routing | | `curved` | `0`, `1` | Curved edges | | `endArrow` | `classic`, `block`, `open`, `oval`, `diamond`, `none` | Arrow head | | `startArrow` | Same as endArrow | Arrow tail | | `endFill` | `0`, `1` | Fill arrow head | | `dashed` | `0`, `1` | Dashed line | | `strokeWidth` | `1`, `2`, `3`... | Line width | ### Preset Color Palette | Color | Hex Code | Usage | |-------|----------|-------| | Light Blue | `#dae8fc` | Information zones | | Light Green | `#d5e8d4` | Success/Cloud zones | | Light Yellow | `#fff2cc` | Warning zones | | Light Orange | `#ffe6cc` | Caution zones | | Light Red | `#f8cecc` | Danger/External zones | | Light Purple | `#e1d5e7` | Special zones | | Light Gray | `#f5f5f5` | Neutral zones | --- ## Common Shapes ### Basic Shapes ```xml ``` ### Container/Swimlane ```xml ``` --- ## Edge Examples ```xml ``` --- ## Complete Example: Simple Architecture ```drawio ``` --- ## Common Pitfalls | Issue | Solution | |-------|----------| | Diagram not rendering | Check `` and `` exist | | Shape not visible | Verify `vertex="1"` and `parent="1"` attributes | | Edge not connecting | Ensure `source` and `target` match cell IDs | | Styles not applying | Check semicolon separators in style string | | Text not showing | Add `html=1;whiteSpace=wrap;` to style | | Overlapping shapes | Adjust x, y coordinates in `` | --- ## Output Format ````markdown ```drawio ``` ```` --- ## Tips for AI Generation 1. **Plan layout first**: Sketch positions mentally before writing XML 2. **Use grid alignment**: Position shapes at multiples of 10 or 20 3. **Layer backgrounds first**: Define zone/container cells before shapes inside them 4. **Unique IDs**: Use descriptive IDs like `client`, `server`, `db` instead of random strings 5. **Consistent spacing**: Keep 40-60px gaps between connected shapes 6. **Color zones**: Use light background colors with `strokeColor=none` for region highlighting --- ## Resources - [Draw.io Documentation](https://www.drawio.com/doc/) - [mxGraph API Reference](https://jgraph.github.io/mxgraph/docs/manual.html)