Scoped surface
Different hue, different radius, same markup.
Every design decision in the framework is a CSS variable or a Sass function. Nothing is hardcoded at a call site.
| Variable | Default | Purpose |
|---|---|---|
--primary | rebeccapurple | The brand colour. Everything derives from this. |
--secondary | the primary | Links |
--neutral | a near-grey on the primary's hue | What text and surfaces are tinted with |
--error | maroon | Invalid inputs, .text-error |
--fallback-color | white | Used by .contrast |
--border-radius | 0.25rem | Base corner radius; the fallback for the three below |
--radius-box | --border-radius | Surfaces: card, dialog, alert, dropdown panel, popover, fieldset, skeleton, progress |
--radius-field | --border-radius | Controls: button, input, select, textarea, tab, menu row, segmented control, tooltip |
--radius-selector | per component | Small marks: checkbox (half the base radius when unset), badge (double it) and toggle (a pill) |
--border-width | 1px | Borders and rules |
--padding | 1rem | Base spacing unit |
--box-shadow | four-layer shadow | Articles and dialogs |
--icon-width | 1rem | Size of input icons |
--icon-position | 0.75rem | Inset of input icons |
--surface, --ink, --edge… | derived | See Colors. Read them; set the inputs instead |
--primary-surface-lc | stop 6 | Primary button background |
--primary-text-lc | stop 1 | Primary button text |
--grey-surface-lc-* | derived | Chroma-free equivalents, used by disabled states |
--primary-color is declared on :root but is not read by any rule.
Primary buttons use --accent with --accent-ink for their text.
Variables cascade, so overriding one on a subtree is the whole customization story. No build step is involved in any of this.
Different hue, different radius, same markup.
<article class="card-border retheme" style="--primary: seagreen; --border-radius: 1rem">
<h3>Scoped surface</h3>
<p>Different hue, different radius, same markup.</p>
<button>Themed button</button>
</article>
Three variables split the corners by kind of component. None is declared:
each falls back to --border-radius where it is used, so
.rounded or any --border-radius you set on a
subtree still reaches all of them. Set one to change only that kind.
<div class="flex flip" style="--radius-box: 1.25rem; --radius-field: 0; --radius-selector: 0.375rem">
<article class="card prose" style="flex: 1">
<h3>Round boxes</h3>
<p><span class="badge">Soft badge</span></p>
<label class="label"><input type="checkbox" class="checkbox" checked /> Soft checkbox</label>
<label class="label"><input type="checkbox" class="toggle" checked /> Soft toggle</label>
</article>
<div style="flex: 1">
<label class="label"><p>Square field</p><input class="input" /></label>
<button class="btn">Square button</button>
</div>
</div>
Without a data-color-scheme attribute, the scheme follows
prefers-color-scheme. Set the attribute to pin it, on <html> or on
any subtree.
Forced light
Forced dark
<div class="flex flip">
<div data-color-scheme="light" class="scheme-pane">
<p><strong>Forced light</strong></p>
<button>Button</button>
</div>
<div data-color-scheme="dark" class="scheme-pane">
<p><strong>Forced dark</strong></p>
<button>Button</button>
</div>
</div>
| Signature | Returns |
|---|---|
tone($input, $lightness, $cap) | The input at a pinned lightness, its chroma capped and scaled by --chroma |
get-color($lc, $color) | An explicit color at stop $lc |
get-grey($lc, $color) | The same, with chroma forced to zero |
oklch-from-vars($color, $lightness) | Lightness override, chroma and hue preserved |
--chroma: 0 | Greys out this element and its subtree |
@include lightSchemeVars() | Emits the full light-mode variable block |
@include darkSchemeVars() | Emits the full dark-mode variable block |
@use "@sparkstone/css/src/vars.scss" as *;
.alert {
--primary: var(--error);
background-color: var(--fill);
color: var(--ink);
border: var(--border-width) solid get-border-color();
border-radius: var(--border-radius);
padding: var(--padding);
}
That is the pattern for your own components: set --primary if you want a different
hue, then pull surfaces and text from the same stops the framework uses. You inherit the contrast
guarantees for free.
Three icons ship as base64 SVG data URLs, redefined per scheme so the stroke flips:
--icon-chevron for select, --icon-calendar for date,
--icon-clock for time. Override any of them with your own data URL.
select {
--icon-chevron: url("data:image/svg+xml;base64,…");
}