Skip to content

Tokens

VS Cookies separates two kinds of custom properties:

  • Global state tokens (--vsc-state-*) are the only variables shipped by @vscookies/tokens. They describe cross-cutting state: danger, focus, stacking order, motion, and the color-scheme driver.
  • Skin UI tokens (--vsc-min-* for Minimalist, --vsc-edito-* for Edito) are owned by each skin package. Every color, radius, space, font, shadow, and blur value lives there, so skins can diverge freely.

Both runtimes bundle the global state layer and re-export the same contract.

The React and vanilla runtimes load the global tokens for you. To link them yourself (for example when using @vscookies/core alone), download the standalone vscookies-tokens-v0.2.0.zip from the VS GOODS store (no dependencies) and:

import "@vscookies/tokens/css";

The runtime CSS entry points are @vscookies/react/tokens.css and @vscookies/vanilla/tokens.css. This sets color-scheme: light dark on :root and defines the --vsc-state-* variables.

VariableDefaultDescription
--vsc-state-dangerlight-dark(#dc2626, #f87171)Error/danger color.
--vsc-state-focuslight-dark(#93c5fd, #1d4ed8)Keyboard focus ring.
--vsc-state-z-banner2147483000Stacking level of the banner.
--vsc-state-transition160ms easeShared motion duration; 0ms under reduced motion.

Light and dark values use the standard CSS light-dark() function. Set data-vsc-theme on an ancestor to force a scheme:

<html data-vsc-theme="dark">

data-vsc-theme="light" opts out of the automatic dark mode. With no attribute, the browser’s preferred scheme wins. Modern evergreen browsers are required for light-dark().

Each skin exports a skinTokens manifest and scopes its variables to its own root. The React root carries data-vsc-skin="<slug>"; the Web Component host gets the same attribute so overrides can target either runtime identically.

SkinPrefixPackage
Minimalist--vsc-min-*@vscookies/skin-minimalist-react / -vanilla
Edito--vsc-edito-*@vscookies/skin-edito-react / -vanilla

Every dimensional value is rem-based so it scales with the host page’s root font size. The only exception is the oversized <prefix>radius-full sentinel (9999px), which the browser clamps to a pill. See each skin page for its full generated token table.

--vsc-global-* is an explicit opt-in override for any skin: the suffix matches the skin token name after its prefix. Scoped declarations target one skin:

:root {
/* Applies to every mounted skin. */
--vsc-global-radius-xl: 0.5rem;
}
[data-vsc-skin="minimalist"] {
/* Applies only to the Minimalist skin. */
--vsc-min-color-accent: #7c3aed;
}

Because the global layer ships light-dark() defaults, a global color override should also use light-dark(light, dark) if you need separate schemes.

Both runtimes export the same contract:

ExportContents
GLOBAL_TOKEN_MANIFESTDescriptors for the four --vsc-state-* tokens.
GLOBAL_TOKEN_NAMESValid global token names.
setTokenOverrides(values, { skin? })Apply or replace overrides for one scope.
clearTokenOverrides({ skin? })Clear one scope.
clearAllTokenOverrides()Clear every scope (global and all skins).
tokens / stateJS values for the global state layer.

Omitting skin targets :root; passing a registered slug writes to [data-vsc-skin="<slug>"]. Each scope owns its own <style> element, so clearing one skin never touches another or the global layer.

import {
GLOBAL_TOKEN_MANIFEST,
GLOBAL_TOKEN_NAMES,
setTokenOverrides,
clearTokenOverrides,
clearAllTokenOverrides,
} from "@vscookies/react"; // or "@vscookies/vanilla"
setTokenOverrides({ "--vsc-global-radius-xl": "0.5rem" });
setTokenOverrides({ "--vsc-min-color-accent": "#7c3aed" }, { skin: "minimalist" });
clearTokenOverrides({ skin: "minimalist" });
clearAllTokenOverrides();

Overrides are intentionally not persisted. These helpers are the building blocks for a live token editor you build yourself; no editor is shipped.

import tokens, { state, GLOBAL_TOKEN_MANIFEST } from "@vscookies/tokens";
import { skinTokens } from "@vscookies/skin-minimalist-react";
state.focus; // "light-dark(#93c5fd, #1d4ed8)"
tokens.state.zBanner; // 2147483000
GLOBAL_TOKEN_MANIFEST[0].name; // "--vsc-state-danger"
skinTokens.tokens[0].name; // "--vsc-min-color-accent"

The runtimes also export tokens, GLOBAL_TOKEN_MANIFEST and GLOBAL_TOKEN_NAMES from their package roots and /tokens subpaths. A skin package exports its own skinTokens and <Skin>TokenName type.

Under prefers-reduced-motion: reduce, --vsc-state-transition becomes 0ms. Every component transition reads that token, so no separate media query is needed in skin CSS.