Design tokens
Shared visual roles for interfaces, documents and diagrams, from their CSS source to scoped rendering and exports.
On this page
Architecture notebook
Describe the system, explain its relationships and keep the evidence beside the conclusion.
Illustrative report · Engineering audience · Draft
Loading diagram…
Diagram source
flowchart LR
client[Client]:::client
service[Service]:::service
client content@-->|Content| service
class content dataflowA token names a recurring visual decision and keeps its value in the shared source. Bosunkit uses CSS custom
properties such as --text-dim, --bk-type-body-reading and --bk-diagram-service. These are the names to use
in code. Dotted names from other design systems describe a similar idea; they are not Bosunkit exports.
Source and delivery
The editable source is design/bosunkit/tokens/. Import @bosunkit/tokens/index.css once before component
styles. Its cascade layers put reset, tokens, components and instruments in a defined order.
| Source | Owns | Consumers |
|---|---|---|
tokens.css | House palette, spacing, surfaces, diagram roles and theme overrides | Interfaces, documents and diagrams |
typography.css | Complete text roles and size-class overrides | Controls, reading text, headings and code |
communications.css | Document aliases, template measure, insets and section spacing | Investor templates and document compositions |
charts.css | Analytical chart geometry and emphasis, and the analytical series palette | Chart components |
openbridge.css, themes.css | OpenBridge palette and theme roles | Instruments and compatible controls |
interaction.css | Control-state aliases over the OpenBridge states | Controls and their states |
focus.css | The focus ring every focusable control draws | Every control |
sizes.css | The size classes, default and helm | Text and controls in a size scope |
flash.css | The alert flash tempos and the properties the blink clock animates | Alerts and the instruments |
layers.css, overlays.css | The stacking order, and dialog geometry | Overlays, the header and the alert zone |
breakpoints.css | The phone and tablet widths, 40em and 68.75em | Components that change form by screen |
navigation.css | Navigation geometry | The app shell and navigation lists |
presentations.css | Slide canvas and slide type | The presentation starter |
fonts.css, reset.css | The bundled IBM Plex faces, and the first-layer resets | Every consumer |
read.ts, write-tokens-json.ts | CSS parsing and generated tokens.json | Foundation tables and static exporters |
tokens.json is generated output, not a second place to edit the design. The parser resolves var() aliases;
CSS expressions such as color-mix() may remain expressions. It is not a complete browser cascade or a snapshot
of a nested size scope. Use the browser's computed styles when rendering depends on a particular element.
@import "@bosunkit/tokens/index.css";
.document-summary {
padding: var(--bk-document-inset);
background: var(--surface);
color: var(--text);
font: var(--bk-document-body);
}From a shared role to a component
| Level | Example in the source | Responsibility |
|---|---|---|
| Palette or scale | --blue, --space-xl | Supply shared color and spacing choices |
| Semantic role | --text-dim, --bk-type-body-reading | Name a purpose across consumers |
| Specialized role | --bk-document-body, --bk-diagram-service | Express a recurring document or diagram need |
| Component mapping | --report-accent | Select an existing role for a particular component instance |
| Compatibility role | --element-active-color | Expose the names consumed by OpenBridge |
The source includes direct values and aliases; it is not a strict three-tier naming schema. Prefer the narrowest
role that expresses the intended meaning. A diagram service fill uses --bk-diagram-service; a component does
not reconstruct that fill from a palette color. The report palette maps accent="01" to
--data-categorical-operational-01 through its local --report-accent variable.
Reading, labels and diagram type
Report prose, metadata and diagram labels need different densities. Enlarging every text element makes a document harder to scan and can misalign controls. Choose the role before changing a size.
| Job | Token | Behavior |
|---|---|---|
| Report title | --bk-document-title | Aliases the page heading role |
| Document section | --bk-document-heading | Aliases the section heading role |
| Sustained reading | --bk-document-body | Aliases --bk-type-body-reading |
| Compact document text | --bk-document-caption | Aliases the body role; this is distinct from the smaller UI caption |
| Metadata label or hint | --bk-type-label, --bk-type-caption | Separates field names from supporting detail |
| Diagram description | --bk-diagram-font-family, --bk-diagram-font-size | Uses the diagram's own label metrics |
| Diagram title | --bk-diagram-title-size | Gives node and group titles a distinct size |
| Service identifier | --font-mono | Used for bold service names in Mermaid |
The diagram family is a neutral sans serif; document and UI roles use the shared body family. Diagram sizes are independent of the UI size-class scale. A scaled SVG scales its text too, so inspect dense drawings at their natural width as well as in the fitted column. Keep UI buttons on their control roles.
--bk-type-body-reading16px / 24px · 400--bk-type-label14px / 20px · 500--bk-type-caption12px / 16px · 400--bk-type-code12px / 18px · 400Reading measure and available space
--bk-report-width sets the standalone report-template measure and is available to document compositions.
--bk-email-width sets the email-template measure. Neither defines the Fumadocs shell's page width or reserves
space for its navigation. Report grids adapt to the space their parent provides.
| Token | Value | rem | Preview |
|---|---|---|---|
--bk-report-width | 760px | 47.5rem |
| Token | Value | rem | Preview |
|---|---|---|---|
--bk-email-width | 600px | 37.5rem |
Keep prose within a reading measure on larger displays. Let diagrams and tables use the available figure area inside the shell. A figure must not cover the sidebar or “On this page.” Mermaid fits its container by default; Expand reveals its natural drawing width inside a horizontal scroll region. Desktop preview can show a larger report composition without widening the documentation page itself.
Insets and section spacing come from --bk-document-inset and --bk-document-section-gap. Diagram padding
and automatic rank spacing use the shared spacing scale. An authored MermaidLayout contains drawing coordinates
and routes; those are content geometry, not CSS tokens or viewport breakpoints.
Editorial color and diagram roles
Report category accents and data-series colors distinguish subjects. They do not establish alert priority, publication approval or confidentiality. Name states in text and preserve category labels, connection names and line patterns when color changes.
Mermaid has separate canvas, group, node, service and connection roles. The Day palette uses a quiet paper surface and softly tinted services. Night, Dusk and Bright each resolve their own values; a Day color copied into diagram source bypasses that behavior.
| Token | Night | Dusk | Day | Bright |
|---|---|---|---|---|
--bk-diagram-canvasDrawing surface | #14100A | #15161A | #FAFBF8 | #ECEEF1 |
--bk-diagram-groupSystem boundary or grouped clients | #0B0803 | #101114 | #EFEEE5 | #F4F5F7 |
--bk-diagram-nodeNeutral node | #14100A | #15161A | #FFFFFF | #ECEEF1 |
--bk-diagram-textLabels and descriptions | #EAA75E | #E7E9EC | #72736E | #0B0C0F |
--bk-diagram-lineNeutral boundaries and connections | #8F6130 | #8B8F98 | #72736E | #4B5058 |
--bk-diagram-serviceService fill | color-mix(in srgb, #5a6673 7%, #14100a) | color-mix(in srgb, #3b82f6 7%, #15161a) | #EDF5FB | color-mix(in srgb, #1d4ed8 7%, #eceef1) |
--bk-diagram-service-lineService boundary | #5A6673 | #3B82F6 | #5691CA | #1D4ED8 |
--bk-diagram-flowNamed content path | #BA5A00 | #F97316 | #D6784C | #C2410C |
Use the shared Mermaid classes client, service, storage and dataflow to opt into these roles. Authored
classDef and style declarations retain precedence. Evaluate text against its actual fill and connectors
against their canvas; a token name alone does not establish sufficient contrast.
Local theme scopes
PresentationScope places theme and size attributes on an element. CSS consumers inherit the nearest scope.
The two diagrams below retain their explicit themes when the site's theme changes.
Loading diagram…
Diagram source
flowchart LR
Client:::client --> Service:::serviceLoading diagram…
Diagram source
flowchart LR
Client:::client --> Service:::serviceRead renderer tokens with getComputedStyle(container) on the diagram's own element. Reading
document.documentElement ignores a local scope. Re-render generated artwork after its effective theme changes;
CSS inheritance alone cannot recolor values already embedded in an SVG string.
Mermaid has global configuration. The shared renderer serializes initialization and rendering so simultaneous
diagrams cannot exchange palettes. It resolves the connection role before adding the dataflow class to Mermaid
source: raw var(--…) syntax is not valid in every diagram grammar position.
SVGs, Markdown and static exports
| Output | Token handling | Content that must survive |
|---|---|---|
| Live CSS component | Inherit roles from its element's scope | Labels, metadata and evidence |
| Generated Mermaid SVG | Resolve renderer values locally and scope generated styles | Diagram relationships, readable labels and accessible description |
| Markdown export | Preserve source and a text explanation | Mermaid fences and report metadata; exact JSX placement is separate |
| Standalone HTML document | Resolve the chosen template theme and embed its styles/fonts | Reading structure and source context |
| Resolve the chosen palette to supported inline styles | Plain-text alternative and meaningful links |
Keep renderer selectors inside their generated diagram. A generic .label rule from a component stylesheet
must not change SVG label metrics. HTML labels can contain line breaks inside SVG foreignObject content;
the shared renderer parses its generated markup as HTML to retain that content without XML tag mismatches.
This does not grant arbitrary diagram HTML permission: strict rendering and source disclosure remain in place.
A copied Mermaid fence retains relationships and automatic layout. Exact reference placement belongs to the
optional JSX layout object. Tokens provide visual consistency; they do not reproduce another drawing's
coordinates, font rasterization or every reference pixel.
Add or change a role
- Find the existing role that owns the meaning. Add a specialized role when several uses need the same visual decision; keep a single diagram's labels and coordinates in its source.
- Define it in the appropriate token stylesheet, including every relevant theme or size scope. Aliases that depend on theme-local values must resolve within each explicit scope.
- Keep
index.css, the token writer and the design site's parser inputs aligned when adding a stylesheet. Regenerate JSON withnode design/bosunkit/tokens/write-tokens-json.ts; do not edit that output manually. - Use the role at the shared component source and document it with a live example. Both documentation and reports consume that component; a specimen must not apply its own corrective styling.
- Verify Night, Dusk, Day and Bright, nested scopes, fitted and expanded diagrams, narrow containers and the relevant static export. Check source disclosure and failure recovery as well as the successful drawing.
Using tokens
A category named “Technical report” does not carry alarm semantics.
--bk-diagram-service → service fillnode placement → MermaidLayout.boxesRelated
- Themes and Typography: scoped palettes and complete text roles.
- Grid and Reports and docs: reading measures and composition.
- Mermaid: diagram classes, authored layouts, source and inspection controls.
- Report blocks and Report metadata: editorial roles in shared components.