Customizing

Every design decision in the framework is a CSS variable or a Sass function. Nothing is hardcoded at a call site.

Variable reference

VariableDefaultPurpose
--primaryrebeccapurpleThe brand colour. Everything derives from this.
--secondarythe primaryLinks
--neutrala near-grey on the primary's hueWhat text and surfaces are tinted with
--errormaroonInvalid inputs, .text-error
--fallback-colorwhiteUsed by .contrast
--border-radius0.25remBase corner radius; the fallback for the three below
--radius-box--border-radiusSurfaces: card, dialog, alert, dropdown panel, popover, fieldset, skeleton, progress
--radius-field--border-radiusControls: button, input, select, textarea, tab, menu row, segmented control, tooltip
--radius-selectorper componentSmall marks: checkbox (half the base radius when unset), badge (double it) and toggle (a pill)
--border-width1pxBorders and rules
--padding1remBase spacing unit
--box-shadowfour-layer shadowArticles and dialogs
--icon-width1remSize of input icons
--icon-position0.75remInset of input icons
--surface, --ink, --edge…derivedSee Colors. Read them; set the inputs instead
--primary-surface-lcstop 6Primary button background
--primary-text-lcstop 1Primary button text
--grey-surface-lc-*derivedChroma-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.

Scoping

Variables cascade, so overriding one on a subtree is the whole customization story. No build step is involved in any of this.

Scoped surface

Different hue, different radius, same markup.

Same markup in both builds
<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>

Corners

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.

Same markup in both builds
<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>

Color scheme

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

Same markup in both builds
<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>

Sass API

SignatureReturns
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: 0Greys 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.

Icons

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,…");
}