Skip to content

Styling and international text ​

Layup uses named palettes and measured typography. The same scene can render light, dark, or automatic themes without changing its geometry.

Palettes and styles ​

The palettes are gray, blue, green, yellow, purple, orange, and red. Omitting a palette gives ordinary nodes automatic colors. Authored layout cycles colors in declaration order; automatic graphs derive them from node IDs so unrelated insertions do not change existing colors.

Ports and adapters{"languageVersion":1,"diagramId":"main","diagrams":["main"],"manifest":[{"id":"main","diagramType":"graph","status":"selected","reason":null,"annotations":[],"span":{"start":0,"end":393,"line":1,"column":1,"endLine":11,"endColumn":2}}],"targets":[],"diagnostics":[],"diagram":{"declaration":"diagram","attributes":{"flow-direction":{"value":{"type":"choice","value":"right"},"span":{"start":57,"end":77,"line":1,"column":58,"endLine":1,"endColumn":78},"valueSpan":{"start":72,"end":77,"line":1,"column":73,"endLine":1,"endColumn":78},"nameSpan":{"start":57,"end":71,"line":1,"column":58,"endLine":1,"endColumn":72}},"layout":{"value":{"type":"choice","value":"auto"},"span":{"start":45,"end":56,"line":1,"column":46,"endLine":1,"endColumn":57},"valueSpan":{"start":52,"end":56,"line":1,"column":53,"endLine":1,"endColumn":57},"nameSpan":{"start":45,"end":51,"line":1,"column":46,"endLine":1,"endColumn":52}},"type":{"value":{"type":"choice","value":"graph"},"span":{"start":34,"end":44,"line":1,"column":35,"endLine":1,"endColumn":45},"valueSpan":{"start":39,"end":44,"line":1,"column":40,"endLine":1,"endColumn":45},"nameSpan":{"start":34,"end":38,"line":1,"column":35,"endLine":1,"endColumn":39}}},"path":null,"authoredId":null,"documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":null,"strokeColor":null,"textColor":null,"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}},"objects":{"object:[\"api\"]":{"declaration":"node","attributes":{"style":{"value":{"type":"choice","value":"service"},"span":{"start":234,"end":247,"line":4,"column":27,"endLine":4,"endColumn":40},"valueSpan":{"start":240,"end":247,"line":4,"column":33,"endLine":4,"endColumn":40},"nameSpan":{"start":234,"end":239,"line":4,"column":27,"endLine":4,"endColumn":32}}},"path":["api"],"authoredId":"api","documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":null,"strokeColor":null,"textColor":null,"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}},"object:[\"repository\"]":{"declaration":"node","attributes":{"style":{"value":{"type":"choice","value":"port"},"span":{"start":308,"end":318,"line":7,"column":32,"endLine":7,"endColumn":42},"valueSpan":{"start":314,"end":318,"line":7,"column":38,"endLine":7,"endColumn":42},"nameSpan":{"start":308,"end":313,"line":7,"column":32,"endLine":7,"endColumn":37}}},"path":["repository"],"authoredId":"repository","documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":{"type":"none"},"strokeColor":null,"textColor":null,"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}}},"relationships":{"anonymous:0":{"declaration":"edge","attributes":{"label":{"value":{"type":"choice","value":"style"},"span":{"start":369,"end":380,"line":10,"column":25,"endLine":10,"endColumn":36},"valueSpan":{"start":375,"end":380,"line":10,"column":31,"endLine":10,"endColumn":36},"nameSpan":{"start":369,"end":374,"line":10,"column":25,"endLine":10,"endColumn":30}},"style":{"value":{"type":"choice","value":"uses"},"span":{"start":381,"end":391,"line":10,"column":37,"endLine":10,"endColumn":47},"valueSpan":{"start":387,"end":391,"line":10,"column":43,"endLine":10,"endColumn":47},"nameSpan":{"start":381,"end":386,"line":10,"column":37,"endLine":10,"endColumn":42}}},"path":null,"authoredId":null,"documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":null,"strokeColor":null,"textColor":null,"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}}}}Copyright © 2017 IBM Corp. with Reserved Font Name "Plex" This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL ----------------------------------------------------------- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ----------------------------------------------------------- PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. "Reserved Font Name" refers to any names specified as such after the copyright statement(s). "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.Ports and adaptersportusesHTTP serviceGET /ordersRepositoryfind(id)uses
text
diagram main "Ports and adapters" type=graph layout=auto flow-direction=right {
  node-style service base=node palette=blue
  node-style port base=interface fill-color=none palette=purple legend-label="port"
  node api "HTTP service" style=service {
    code "GET /orders"
  }
  node repository "Repository" style=port {
    code "find(id)"
  }
  ::api -> ::repository label=style style=uses
}

base= inherits a style; shape= selects graph geometry. fill-color=none removes fill, font-family=mono|sans selects header typography, and text-align= controls alignment. role= adds a visible role label and tag "..." supplies explicit context. Direct fill/stroke/text colors can use {light: COLOR, dark: COLOR} values. Connection styles are listed in the DSL reference.

Independent paint channels ​

Paint properties override the coordinated palette without changing layout. Literal colors stay literal in light and dark exports; theme pairs adapt. Setting auto resets an inherited override and none removes fill or stroke. A container's paint does not implicitly propagate to its children.

Direct paint{"languageVersion":1,"diagramId":"paint","diagrams":["paint"],"manifest":[{"id":"paint","diagramType":"graph","status":"selected","reason":null,"annotations":[],"span":{"start":0,"end":524,"line":1,"column":1,"endLine":6,"endColumn":2}}],"targets":[],"diagnostics":[],"diagram":{"declaration":"diagram","attributes":{"background-color":{"value":{"type":"record","value":{"dark":{"type":"string","value":"#101827"},"light":{"type":"string","value":"#ffffff"}}},"span":{"start":73,"end":125,"line":1,"column":74,"endLine":1,"endColumn":126},"valueSpan":{"start":90,"end":125,"line":1,"column":91,"endLine":1,"endColumn":126},"nameSpan":{"start":73,"end":89,"line":1,"column":74,"endLine":1,"endColumn":90}},"flow-direction":{"value":{"type":"choice","value":"right"},"span":{"start":52,"end":72,"line":1,"column":53,"endLine":1,"endColumn":73},"valueSpan":{"start":67,"end":72,"line":1,"column":68,"endLine":1,"endColumn":73},"nameSpan":{"start":52,"end":66,"line":1,"column":53,"endLine":1,"endColumn":67}},"layout":{"value":{"type":"choice","value":"auto"},"span":{"start":40,"end":51,"line":1,"column":41,"endLine":1,"endColumn":52},"valueSpan":{"start":47,"end":51,"line":1,"column":48,"endLine":1,"endColumn":52},"nameSpan":{"start":40,"end":46,"line":1,"column":41,"endLine":1,"endColumn":47}},"type":{"value":{"type":"choice","value":"graph"},"span":{"start":29,"end":39,"line":1,"column":30,"endLine":1,"endColumn":40},"valueSpan":{"start":34,"end":39,"line":1,"column":35,"endLine":1,"endColumn":40},"nameSpan":{"start":29,"end":33,"line":1,"column":30,"endLine":1,"endColumn":34}}},"path":null,"authoredId":null,"documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":null,"strokeColor":null,"textColor":null,"backgroundColor":{"type":"themed","value":{"light":{"type":"literal","value":"#ffffff"},"dark":{"type":"literal","value":"#101827"}}},"strokeStyle":null,"strokeWidth":null}},"objects":{"object:[\"api\"]":{"declaration":"node","attributes":{"style":{"value":{"type":"choice","value":"service"},"span":{"start":335,"end":348,"line":3,"column":18,"endLine":3,"endColumn":31},"valueSpan":{"start":341,"end":348,"line":3,"column":24,"endLine":3,"endColumn":31},"nameSpan":{"start":335,"end":340,"line":3,"column":18,"endLine":3,"endColumn":23}}},"path":["api"],"authoredId":"api","documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":{"type":"themed","value":{"light":{"type":"literal","value":"#eff6ff"},"dark":{"type":"literal","value":"#172554"}}},"strokeColor":{"type":"themed","value":{"light":{"type":"literal","value":"#1d4ed8"},"dark":{"type":"literal","value":"#93c5fd"}}},"textColor":{"type":"themed","value":{"light":{"type":"literal","value":"#1e3a8a"},"dark":{"type":"literal","value":"#bfdbfe"}}},"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}},"object:[\"worker\"]":{"declaration":"node","attributes":{"palette":{"value":{"type":"choice","value":"green"},"span":{"start":386,"end":399,"line":4,"column":38,"endLine":4,"endColumn":51},"valueSpan":{"start":394,"end":399,"line":4,"column":46,"endLine":4,"endColumn":51},"nameSpan":{"start":386,"end":393,"line":4,"column":38,"endLine":4,"endColumn":45}},"style":{"value":{"type":"choice","value":"service"},"span":{"start":372,"end":385,"line":4,"column":24,"endLine":4,"endColumn":37},"valueSpan":{"start":378,"end":385,"line":4,"column":30,"endLine":4,"endColumn":37},"nameSpan":{"start":372,"end":377,"line":4,"column":24,"endLine":4,"endColumn":29}}},"path":["worker"],"authoredId":"worker","documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":{"type":"themed","value":{"light":{"type":"literal","value":"#eff6ff"},"dark":{"type":"literal","value":"#172554"}}},"strokeColor":{"type":"themed","value":{"light":{"type":"literal","value":"#1d4ed8"},"dark":{"type":"literal","value":"#93c5fd"}}},"textColor":{"type":"themed","value":{"light":{"type":"literal","value":"#1e3a8a"},"dark":{"type":"literal","value":"#bfdbfe"}}},"backgroundColor":null,"strokeStyle":null,"strokeWidth":null}}},"relationships":{"relationship:\"request\"":{"declaration":"edge","attributes":{"stroke-color":{"value":{"type":"record","value":{"dark":{"type":"string","value":"#93c5fd"},"light":{"type":"string","value":"#1d4ed8"}}},"span":{"start":439,"end":487,"line":5,"column":40,"endLine":5,"endColumn":88},"valueSpan":{"start":452,"end":487,"line":5,"column":53,"endLine":5,"endColumn":88},"nameSpan":{"start":439,"end":451,"line":5,"column":40,"endLine":5,"endColumn":52}},"stroke-style":{"value":{"type":"choice","value":"dotted"},"span":{"start":488,"end":507,"line":5,"column":89,"endLine":5,"endColumn":108},"valueSpan":{"start":501,"end":507,"line":5,"column":102,"endLine":5,"endColumn":108},"nameSpan":{"start":488,"end":500,"line":5,"column":89,"endLine":5,"endColumn":101}},"stroke-width":{"value":{"type":"integer","value":"2"},"span":{"start":508,"end":522,"line":5,"column":109,"endLine":5,"endColumn":123},"valueSpan":{"start":521,"end":522,"line":5,"column":122,"endLine":5,"endColumn":123},"nameSpan":{"start":508,"end":520,"line":5,"column":109,"endLine":5,"endColumn":121}}},"path":null,"authoredId":"request","documentation":null,"sourceLocations":[],"metadata":{},"annotations":[],"paint":{"paletteOrigin":null,"fillColor":null,"strokeColor":{"type":"themed","value":{"light":{"type":"literal","value":"#1d4ed8"},"dark":{"type":"literal","value":"#93c5fd"}}},"textColor":null,"backgroundColor":null,"strokeStyle":"dotted","strokeWidth":2.0}}}}Copyright © 2017 IBM Corp. with Reserved Font Name "Plex" This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL ----------------------------------------------------------- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ----------------------------------------------------------- PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. "Reserved Font Name" refers to any names specified as such after the copyright statement(s). "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.Direct paintAPIWorkerrequest
text
diagram paint "Direct paint" type=graph layout=auto flow-direction=right background-color={light: "#ffffff", dark: "#101827"} {
  node-style service base=process palette=blue fill-color={light: "#eff6ff", dark: "#172554"} stroke-color={light: "#1d4ed8", dark: "#93c5fd"} text-color={light: "#1e3a8a", dark: "#bfdbfe"}
  node api "API" style=service
  node worker "Worker" style=service palette=green
  edge request api -> worker "request" stroke-color={light: "#1d4ed8", dark: "#93c5fd"} stroke-style=dotted stroke-width=2
}

The paint example also separates default-label from legend-label and combines inherited styles with a rectangle outline and no fill. Legend samples retain declared style paint; instance overrides remain local to their objects. Colors can be literals, theme tokens (background, text, muted, code, frame), or light/dark pairs.

Try the paint example in the playground, including both themes and inherited overrides.

Direction and Unicode ​

Graph flow and text direction are independent. Set text-direction=auto|ltr|rtl on a diagram or node. auto follows the first strong paragraph character. Node overrides apply to descendants, and code runs stay isolated left-to-right inside RTL prose.

text-align=start|end follows text direction; left, right, and center are physical alignments. CJK prose wraps at Unicode line-break opportunities, including punctuation rules, without requiring spaces. Explicit newlines create additional text lines. Arabic and Hebrew use shaped glyphs.

Diagram Loading renderer…
Your diagram appears here. The renderer loads once and runs in your browser.

Ctrl+Enter renders now · Tab moves focus · Click a diagnostic to select its source · Expand for pan, zoom and presentation controls

Use your own fallback fonts

CJK uses your system fonts by default. Choose standalone .ttf/.otf faces for exact measurement and embedding. Files stay in this browser; share links do not include fonts.

System fonts or supplied fonts ​

Latin, Mono, Arabic, and Hebrew faces are bundled. No CJK font is bundled. By default, the viewer supplies CJK glyphs and the compiler estimates their widths. Appearance and exact wrapping can vary between systems.

For reproducible fallback measurement, pass a standalone OpenType or TrueType face. Supplied fonts are tried after bundled fonts, measured, and embedded whole when used. Collections (.ttc) are not supported. Large CJK faces can substantially increase SVG/HTML size.

sh
layup render international.layup --font /path/to/CJK-Regular.ttf
layup check international.layup --font /path/to/CJK-Regular.ttf --strict
js
const fontBytes = new Uint8Array(await (await fetch('/fonts/CJK-Regular.ttf')).arrayBuffer());
const result = engine.render(source, { fonts: [fontBytes] });

The live editor's Use your own fallback fonts section accepts local files; they stay in the browser. Share links carry source and view selection, not font bytes. Recipients can select their own matching font.

An inline host can choose a system family through CSS:

css
.layup { --layup-font-fallback: "Noto Sans CJK SC", sans-serif; }

CSS changes viewer appearance; it does not give the engine exact metrics. For font licensing and provenance, see the bundled-font documentation.

MIT OR Apache-2.0 · Bundled fonts: SIL OFL 1.1