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 thecolor-schemedriver. - 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.
Install and load the global CSS
Section titled “Install and load the global CSS”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.
Global state tokens
Section titled “Global state tokens”| Variable | Default | Description |
|---|---|---|
--vsc-state-danger | light-dark(#dc2626, #f87171) | Error/danger color. |
--vsc-state-focus | light-dark(#93c5fd, #1d4ed8) | Keyboard focus ring. |
--vsc-state-z-banner | 2147483000 | Stacking level of the banner. |
--vsc-state-transition | 160ms ease | Shared 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().
Skin UI tokens
Section titled “Skin UI tokens”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.
| Skin | Prefix | Package |
|---|---|---|
| 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.
Override tokens statically
Section titled “Override tokens statically”--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.
Runtime token contract
Section titled “Runtime token contract”Both runtimes export the same contract:
| Export | Contents |
|---|---|
GLOBAL_TOKEN_MANIFEST | Descriptors for the four --vsc-state-* tokens. |
GLOBAL_TOKEN_NAMES | Valid 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 / state | JS 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.
JavaScript tokens
Section titled “JavaScript tokens”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; // 2147483000GLOBAL_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.
Reduced motion
Section titled “Reduced motion”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.