Skip to content
design
Foundations

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…

The same foundation, with diagram roles.
Diagram source
flowchart LR
  client[Client]:::client
  service[Service]:::service
  client content@-->|Content| service
  class content dataflow
One theme, different jobs. Report context uses reading and editorial roles; the diagram uses canvas, service and connection roles. Change the site theme to see both follow it.
01Choose by meaningA role describes its job: reading text, a service boundary or an editorial category. Similar colors do not make roles interchangeable.
02Resolve in contextComponents inherit their nearest theme and size scope. Rendered SVGs and exported documents need that context explicitly.
03Separate appearance from contentTokens own recurring visual choices. Report facts, labels, diagram relationships and authored coordinates belong to content.

A 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.

SourceOwnsConsumers
tokens.cssHouse palette, spacing, surfaces, diagram roles and theme overridesInterfaces, documents and diagrams
typography.cssComplete text roles and size-class overridesControls, reading text, headings and code
communications.cssDocument aliases, template measure, insets and section spacingInvestor templates and document compositions
charts.cssAnalytical chart geometry and emphasis, and the analytical series paletteChart components
openbridge.css, themes.cssOpenBridge palette and theme rolesInstruments and compatible controls
interaction.cssControl-state aliases over the OpenBridge statesControls and their states
focus.cssThe focus ring every focusable control drawsEvery control
sizes.cssThe size classes, default and helmText and controls in a size scope
flash.cssThe alert flash tempos and the properties the blink clock animatesAlerts and the instruments
layers.css, overlays.cssThe stacking order, and dialog geometryOverlays, the header and the alert zone
breakpoints.cssThe phone and tablet widths, 40em and 68.75emComponents that change form by screen
navigation.cssNavigation geometryThe app shell and navigation lists
presentations.cssSlide canvas and slide typeThe presentation starter
fonts.css, reset.cssThe bundled IBM Plex faces, and the first-layer resetsEvery consumer
read.ts, write-tokens-json.tsCSS parsing and generated tokens.jsonFoundation 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

LevelExample in the sourceResponsibility
Palette or scale--blue, --space-xlSupply shared color and spacing choices
Semantic role--text-dim, --bk-type-body-readingName a purpose across consumers
Specialized role--bk-document-body, --bk-diagram-serviceExpress a recurring document or diagram need
Component mapping--report-accentSelect an existing role for a particular component instance
Compatibility role--element-active-colorExpose 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.

JobTokenBehavior
Report title--bk-document-titleAliases the page heading role
Document section--bk-document-headingAliases the section heading role
Sustained reading--bk-document-bodyAliases --bk-type-body-reading
Compact document text--bk-document-captionAliases the body role; this is distinct from the smaller UI caption
Metadata label or hint--bk-type-label, --bk-type-captionSeparates field names from supporting detail
Diagram description--bk-diagram-font-family, --bk-diagram-font-sizeUses the diagram's own label metrics
Diagram title--bk-diagram-title-sizeGives node and group titles a distinct size
Service identifier--font-monoUsed 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.

The service resolves the request from the regional cache.
ReadingExplanation and evidence--bk-type-body-reading16px / 24px · 400
Prepared for
LabelMetadata field name--bk-type-label14px / 20px · 500
Illustrative architecture · Source retained
CaptionSupporting context--bk-type-caption12px / 16px · 400
cache-service
CodeSource and identifiers--bk-type-code12px / 18px · 400

Reading 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.

TokenValueremPreview
--bk-report-width760px47.5rem
TokenValueremPreview
--bk-email-width600px37.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.

TokenNightDuskDayBright
--bk-diagram-canvas
Drawing surface
#14100A
#15161A
#FAFBF8
#ECEEF1
--bk-diagram-group
System boundary or grouped clients
#0B0803
#101114
#EFEEE5
#F4F5F7
--bk-diagram-node
Neutral node
#14100A
#15161A
#FFFFFF
#ECEEF1
--bk-diagram-text
Labels and descriptions
#EAA75E
#E7E9EC
#72736E
#0B0C0F
--bk-diagram-line
Neutral boundaries and connections
#8F6130
#8B8F98
#72736E
#4B5058
--bk-diagram-service
Service 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-line
Service boundary
#5A6673
#3B82F6
#5691CA
#1D4ED8
--bk-diagram-flow
Named 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…

Explicit Day scope
Diagram source
flowchart LR
  Client:::client --> Service:::service

Loading diagram…

Explicit Night scope
Diagram source
flowchart LR
  Client:::client --> Service:::service
Independent diagram scopes

Read 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

OutputToken handlingContent that must survive
Live CSS componentInherit roles from its element's scopeLabels, metadata and evidence
Generated Mermaid SVGResolve renderer values locally and scope generated stylesDiagram relationships, readable labels and accessible description
Markdown exportPreserve source and a text explanationMermaid fences and report metadata; exact JSX placement is separate
Standalone HTML documentResolve the chosen template theme and embed its styles/fontsReading structure and source context
EmailResolve the chosen palette to supported inline stylesPlain-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

  1. 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.
  2. 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.
  3. Keep index.css, the token writer and the design site's parser inputs aligned when adding a stylesheet. Regenerate JSON with node design/bosunkit/tokens/write-tokens-json.ts; do not edit that output manually.
  4. 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.
  5. 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

Do
Service boundary
Choose the role for the job; the service stays recognizable across themes.
Don't

A category named “Technical report” does not carry alarm semantics.

Do not assign an alert priority to a report category or approval state.
Do
--bk-diagram-service → service fill
Keep reusable appearance in tokens and authored geometry in the drawing.
Don't
node placement → MermaidLayout.boxes
Do not create a foundation token for one diagram's node position.