Skip to content
D
Documentation

Themes — interfaces

reference
3 min readUpdated

Interfaces

Import these from @grafloria/renderer.

Interfaces

CascadeOptions

ts
interface CascadeOptions

Properties

NameTypeDefaultDescription
includeThemeBase?booleanInclude the theme base as layer 1. Programmatic/Canvas mode must (there is no stylesheet); CSS mode must NOT (the stylesheet paints it, and inlining it would defeat the theme fallback and the CSS-variable scoping).
connection?Partial<LinkStyle>LINKS ONLY — the highlightConnected layer for a line touching the selection. It sits over the link's own style and its hover, and UNDER a selected or highlighted link's state: a line the user selected keeps the selection's look.

ColorPreferences

The OS-level preferences that decide which theme wins.

ts
interface ColorPreferences

Properties

NameTypeDefaultDescription
prefersDarkbooleanprefers-color-scheme: dark
prefersContrastbooleanprefers-contrast: more
forcedColorsbooleanforced-colors: active — Windows High Contrast and friends.

ContrastCheck

One checked pair.

ts
interface ContrastCheck

Properties

NameTypeDefaultDescription
idstringtext.primary on node.fill — human-readable, stable enough to assert on.
kind'text' | 'selection' | 'state' | 'link' | 'port' | 'category'Broad bucket, so callers can enforce selectively.
foregroundstring
backgroundstring
ratio?numberUndefined when a colour could not be parsed (system colour, gradient, …).
requirednumberThe WCAG minimum this pair is held to.
passesbooleanfalse only when we could measure it AND it fell short.
exempt?booleanWCAG lets disabled/inactive controls off; reported, never enforced.

ContrastReport

ts
interface ContrastReport

Properties

NameTypeDefaultDescription
themestring
checksContrastCheck[]
failuresContrastCheck[]Non-exempt checks that failed.
passesbooleanTrue when nothing enforceable failed.

DeriveThemeOptions

ts
interface DeriveThemeOptions

Properties

NameTypeDefaultDescription
fromThemeThe theme to derive FROM (normally a hand-tuned light theme).
mode'dark' | 'high-contrast'What to build: 'dark' — the dark counterpart (flip the surfaces, keep the hues) 'high-contrast' — same colour scheme, pushed to AAA text / strong strokes
name?stringName of the result. Defaults to "<from> (Dark)" / "<from> (High Contrast)".
textLevel?numberText level the result is repaired to. Default AA; the HC themes use AAA.

Hsl

HSL — the space the light↔dark flip has to happen in (see below).

ts
interface Hsl

Properties

NameTypeDefaultDescription
hnumber0-360
snumber0-1
lnumber0-1

Rgb

sRGB channels, 0-255.

ts
interface Rgb

Properties

NameTypeDefaultDescription
rnumber
gnumber
bnumber

StyleRule

A single CSS rule in the shared stylesheet.

ts
interface StyleRule

Properties

NameTypeDefaultDescription
selectorstringSelector WITHOUT the instance scope (added by {@link generateBaseStyleSheet}).
declsRecord<string, string>Declarations, in CSS property form (stroke-width, not strokeWidth).

ThemeRef

A reference to a theme token, usable anywhere a literal style value is. Opaque on purpose: build it with {@link themeRef}, read it with {@link resolveThemeRef}.

ts
interface ThemeRef

Members

  • readonly [THEME_REF_MARKER]: string
  • readonly [THEME_REF_MARKER]: string

ThemeSet

The themes a renderer can switch BETWEEN. light/dark are required (they are what colorMode selects); the high-contrast pair is optional and only consulted when the user has actually asked for contrast.

ts
interface ThemeSet

Properties

NameTypeDefaultDescription
lightTheme
darkTheme
highContrastLight?Theme
highContrastDark?Theme

ThemeVarBinding

One token's binding: the custom property + how to read its value from a Theme.

ts
interface ThemeVarBinding

Properties

NameTypeDefaultDescription
cssVarstringCSS custom property name, e.g. --grafloria-node-fill.
read(theme: Theme) => string | numberPull the raw value out of a Theme.
unit?'px'Appended when serializing a numeric value into CSS.

Was this page helpful?

Themes — interfaces — Grafloria