RFC 0037 — Theme Studio: the app's own look, checked as it's made
Status: implemented (2026-11-19) · Target: 0.49.0 · builds on RFC 0012, RFC 0014 and RFC 0034 · see Decisions
Summary
Every Elyra app is drawn from the same tokens in @elyra/ui/tokens.css:
about twenty colours, a radius, a spacing, a font. An app that changes
none of them looks like every other Elyra app, and one that changes them
by hand finds out about a contrast it broke when a user can't read a
label. Theme Studio is a panel in the inspector, in a debug build, for
changing them while seeing the app:
- Drag a colour, the radius or the spacing, and every window of the app changes at once: the frames of the matrix (RFC 0034) too, so dark, light and more contrast are seen side by side.
- Every pair that has to be readable is checked as you go: text and muted text on each surface, the accent's text on the accent, borders and the focus ring. A pair that falls below its ratio says so, with the ratio.
- Copy the result as CSS for
app/src/app.css, only the tokens that changed, for dark and for light.
The same check runs on the framework's own tokens in its tests, so what
tokens.css promises ("secondary text at 7:1 or more") is held.
Motivation
- The tokens are the app's look, and only a few people change them.
rata newwrites anapp.cssthat says "override any token here", and then the developer has to know which of the twenty does what, and see each in dark, light and more contrast. - Contrast is easy to break and hard to see, the framework's own
included. Computed for this RFC,
--elyra-mutedin the dark theme is 4.40:1 on--elyra-bgand 3.93:1 on--elyra-inset, and in light 4.25:1 on--elyra-inset: under the 4.5:1 WCAG asks of text. It looks fine on a good screen. Every other text pair passes, from 4.74:1 (the accent's text in light) to 13.55:1. tokens.cssmakes promises nothing checks. Its more-contrast block says secondary text is at 7:1 or more and borders and focus at 3:1 on every surface. They hold today (muted 7.61:1 at least, borders 3.30:1), but no test computes a ratio, so the next change could break them.- The matrix already shows every look at once. What's missing is a way to change the tokens and watch all of them follow.
Current state (0.49)
tokens.css: dark under:root, light under[data-theme="light"], more contrast underprefers-contrast: moreand[data-contrast="more"], motion underprefers-reduced-motion. The tests check that the themes declare the same tokens and that the two more-contrast blocks agree. No ratio is computed.app.cssin a new app importstokens.cssfirst, and overrides after it.- The inspector (RFC 0014) is a drawer in the page, debug only. The matrix (RFC 0034) opens frames that are real windows.
Design
The panel
Theme in the inspector's header opens the studio in the drawer:
- Colours, grouped as
tokens.cssgroups them (surfaces, text, border and focus, accent, status), each with a colour picker and its hex value, for the theme being edited: Dark or Light, a switch at the top. More contrast is edited under its own switch, since its values are separate. - Shape and space:
--elyra-radius,--elyra-radius-lgand--elyra-spaceas sliders, and--elyra-font-size. - Font:
--elyra-fontfrom a short list (the system font, and the fonts the page has loaded), or typed. - Reset each token, or all.
Every window follows
A change is sent to the shell (/__inspector/theme), which keeps the
draft for this run and sends it on elyra:theme-draft to every window.
@elyra/runtime writes it into one <style id="elyra-theme-draft"> at the
end of <head>, after the app's CSS, so it wins:
:root { --elyra-accent: #f97316; }
:root[data-theme="light"] { --elyra-accent: #c2410c; }
Each window draws it in its own look: a matrix frame in light shows the light value. A window opened later gets the draft when it starts. Nothing is written to a file, and quitting the app forgets the draft.
The checks
For the theme being edited, each pair is computed from the colours the
page actually resolves (getComputedStyle), with WCAG's relative
luminance, and listed with its ratio:
| Pair | Needs | More contrast needs |
|---|---|---|
--elyra-text on each surface (bg, surface, raised, inset) |
4.5:1 | 7:1 |
--elyra-muted on each surface |
4.5:1 | 7:1 |
--elyra-on-accent on --elyra-accent |
4.5:1 | 4.5:1 |
--elyra-danger, --elyra-success, --elyra-warning on bg |
3:1 | 4.5:1 |
--elyra-border on each surface |
— (a divider; today 1.15–1.39:1) | 3:1 |
--elyra-focus on each surface |
3:1 | 3:1 |
A pair below its ratio is marked, with the ratio and the colour that
would meet it nearest to the one chosen ("#8a8fb0 would be 4.5:1").
--elyra-border is a divider in the default look, and isn't held to a
ratio there; an input's edge is told by its --elyra-inset fill as much as
its border. Under more contrast, where tokens.css promises 3:1, it is.
Status colours are held to 3:1, since @elyra/ui never sets body text in
them; their text on a soft background is checked as text.
Taking it with you
Copy as CSS puts the changed tokens on the clipboard as blocks for
app/src/app.css: :root, :root[data-theme="light"], and the
more-contrast blocks only when they changed. Only what differs from
tokens.css is in it, with a comment saying where it came from and which
checks it passes.
In the framework's tests
The contrast function lives in @elyra/ui (contrast(a, b), exported
for an app's own tests) and the runtime's studio uses the same. A new test
in tokens.test.js computes every pair above for dark, light and both
more-contrast blocks, so tokens.css can't drift below what it promises.
Security
Debug only, as the inspector is. The draft lives in the shell's memory
for the run and is a stylesheet of --elyra-* values: the shell accepts
only token names it knows and values without ;, {, } or url(, so
the draft can't carry other CSS into the windows.
Testing
contrast()against WCAG's examples, and the tokens test above.- The runtime: the draft lands in one
<style>after the app's, a new window gets it, and a value that isn't a token or carries}is refused. - The shell:
/__inspector/themekeeps, sends and resets the draft; not in a release (inspector_release.rs). - By hand: the example app with the matrix open, the accent dragged, the
three frames following, a failing pair marked, the CSS copied into
app.css.
Implementation plan
contrast()in@elyra/ui, and the tokens test.--elyra-mutedchanges in both themes to reach 4.5:1 on every surface, as close to today's colour as it can be./__inspector/themeandelyra:theme-draft; the runtime's<style>.- The panel in the inspector: tokens, checks, copy as CSS.
- Docs:
docs/ui/tokens.md(a section),docs/inspector.md.
As built
@elyra/ui'scontrast(), withnearest(),luminance()andparseColor(), andtokens.test.jsholding all four looks to the table above. The test caught what this RFC measured, andtokens.csschanged to pass it:--elyra-mutedis#8387a2in dark (was#787c99) and#676b7bin light (was#6b7080), the nearest colours at 4.5:1 on every surface; light's more-contrast blocks set darker status colours (#ca2c46,#357937,#94610b) at 4.5:1. The runtime's own fallback for muted text changed with it.- The runtime has a copy of the contrast function (
themeContrast,themeChecks), since@elyra/runtimecan't depend on@elyra/ui. Both are tested against the same WCAG examples. - The draft has no
!important. It would win over the more-contrast values too, so a dark accent tried in the studio would also replace the more-contrast frame's muted text. It's one<style>moved to the end of<head>on every change, with dark's values under:root:not([data-theme="light"]): after the app's CSS, but belowtokens.css's more-contrast selectors. - Tokens are read from the page's stylesheets (
document.styleSheets, the same selectorstokens.cssuses), with the draft over them, so a look the window isn't in is checked too. A stylesheet from another origin can't be read and is skipped. - The draft starts in a debug build only: the runtime subscribes to
elyra:theme-draftwhen the agent script (RFC 0026) is on the page, which a release never has. - Checked by hand in the example app on macOS, with the matrix open and
the studio driven through
rata mcp dev: 25 of 25 pairs readable; a dark accent of#f97316and a muted of#555a70gave "4 of 25 pairs fall short" with#848797offered; the dark frame took both, the light frame neither, and the more-contrast frame the accent but its own muted text.
Not in this RFC
- Writing
app.cssfrom the app. The app would edit the developer's source; the clipboard is a step more, and leaves the file to the developer and Git. - A palette from one colour. Deriving
accent-soft,focusand the surfaces from a brand colour is a design question of its own. - A check in
rata checkof an app's own overrides inapp.css. It would need the cascade resolved without a browser; the studio and the app's tests withcontrast()cover it for now.
Alternatives considered
- A page in the
@elyra/uireference (npm run docs) instead of the inspector. It shows the components, not the app, and an app's own screens are what the tokens have to work for. - Editing in the browser's dev tools. The tokens are there, but one at a time, in one window, with no ratios and nothing to copy back.
Decisions
- In the inspector, as a panel, as the other developer tools are.
- The draft lives in the shell, so every window and every matrix frame follows.
- Status colours at 3:1, and 4.5:1 under more contrast. Light's are 3.39–4.36:1 today, so its more-contrast block gets darker ones.
- Copy, not write. The CSS goes on the clipboard; the app never edits
app.css. --elyra-mutedchanges in 0.51 to reach 4.5:1 on every surface, as close to today's colour as it can be, noted under Changed in the changelog.- Borders are dividers in the default look, held to no ratio there, and to 3:1 under more contrast.