Tokens come from an inline DTCG-shaped const object. Every leaf is a token (see "Tokens") reached by property access. Values are DTCG values or CSS strings checked by the grammar of their $type. Aliases use DTCG {path} references.
import * as import csscss from "cssints" with { type: "cssints" };
const const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t = import csscss.const createTokens: <{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>(tokens: {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
} & ValidGroup<...>, name?: (path: readonly string[]) => string | TokenName) => css.Tokens<...>
Tokens from an inline DTCG-shaped `const` object: `$type` is inherited through groups, a leaf is `{ $value }`, a value is
a DTCG value or a CSS string of the type's grammar, an alias is `"{group.token}"`. The variable is the kebab-case path
(`--color-bg`), or what the mapper returns for the path.createTokens({
color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
} & ValidGroup<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color: {
$type: "color"$type: "color",
bg: {
readonly $value: "#ffffff";
}
bg: { $value: "#ffffff"$value: "#ffffff" },
fg: {
readonly $value: "#111827";
}
fg: { $value: "#111827"$value: "#111827" },
accent: {
readonly $value: "oklch(62% 0.19 259)";
}
accent: { $value: "oklch(62% 0.19 259)"$value: "oklch(62% 0.19 259)" },
link: {
readonly $value: "{color.accent}";
}
link: { $value: "{color.accent}"$value: "{color.accent}" },
},
space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
} & ValidGroup<{
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
}, "dimension", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
space: { $type: "dimension"$type: "dimension", md: {
readonly $value: "16px";
}
md: { $value: "16px"$value: "16px" } },
});
const const dark: css.QueryWrapdark = import csscss.const media: Condition
<"(prefers-color-scheme: dark)">(query: "(prefers-color-scheme: dark)") => css.QueryWrap (+2 overloads)
media("(prefers-color-scheme: dark)");
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t, const dark: css.QueryWrapdark, { color: {
readonly bg: "#0b0b0f";
readonly fg: "#f3f4f6";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
readonly bg: "#0b0b0f";
readonly fg: "#f3f4f6";
}, css.Tokens<...>>
color: { bg: "#0b0b0f"bg: "#0b0b0f", fg: "#f3f4f6"fg: "#f3f4f6" } });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t, ".light", { color: {
readonly bg: "#fff";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
readonly bg: "#fff";
}, css.Tokens<...>>
color: { bg: "#fff"bg: "#fff" } });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.color: css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color, import csscss.const container: Condition
<"(width < 30rem)">(query: "(width < 30rem)") => css.QueryWrap (+2 overloads)
container("(width < 30rem)"), { bg: "#eee"bg: "#eee" });
import csscss.const check: {
readonly contrast: <F extends TokenType, B extends TokenType>(fg: Token<F, boolean> & ColourOrAny<F>, bg: Token<B, boolean> & ColourOrAny<B>, options: {
readonly min: number;
}) => void;
}
Build-time checks over tokens.check.contrast: <"color", "color">(fg: Token<"color", boolean, string>, bg: Token<"color", boolean, string>, options: {
readonly min: number;
}) => void
WCAG 2.x contrast of `fg` on `bg`, for the defaults and every theme that affects either; below `min` is a build error.
A token from a JSON import has every type to the editor, so it fits; the build checks it is a colour.contrast(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.color: css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color.fg: Token<"color", true, "#111827">fg, const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.color: css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color.bg: Token<"color", true, "#ffffff">bg, { min: numbermin: 4.5 });
export const const A: () => anyA = () => <IntrinsicElements[string]: anydiv className?: string | undefinedclassName={import csscss.const cn: (...styles: css.Style[]) => css.Stylecn(import csscss.const bg: <readonly [Token<"color", true, "#ffffff">]>(parts_0: Token<"color", true, "#ffffff">) => css.Style`<color>`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/background-color)bg(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.color: css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color.bg: Token<"color", true, "#ffffff">bg), import csscss.const color: <readonly [Token<"color", true, "#111827">]>(parts_0: Token<"color", true, "#111827">) => css.Style`<color>`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/color)color(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.color: css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
color.fg: Token<"color", true, "#111827">fg), import csscss.const p: <readonly [Token<"length", true, "16px">]>(parts_0: Token<"length", true, "16px">) => css.Style`<'padding-top'>{1,4}`. Chrome 1, Edge 12, Firefox 1, Safari 1, iOS 1, Android 18. [MDN](https://developer.mozilla.org/docs/Web/CSS/padding)p(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t.space: css.Tokens<{
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
}, "dimension", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
space.md: Token<"length", true, "16px">md))} />;
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, css.Overrides<...>, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: css.Overrides<...> & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t, const dark: css.QueryWrapdark, { color?: (css.Overrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>> & css.CheckOverrides<...>) | undefined
color: { nope: "red" } }); // error: no token at this pathimport csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>
t, css.hover, { color: {
readonly bg: "red";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#ffffff";
};
readonly fg: {
readonly $value: "#111827";
};
readonly accent: {
readonly $value: "oklch(62% 0.19 259)";
};
readonly link: {
readonly $value: "{color.accent}";
};
};
readonly space: {
readonly $type: "dimension";
readonly md: {
readonly $value: "16px";
};
};
}>, {
readonly bg: "red";
}, css.Tokens<...>>
color: { bg: "red"bg: "red" } }); // error: a pseudo-class is not a theme condition$type is inherited through groups, and a token needs one (it is not guessed from the value). It maps to a token type: color to color, dimension to length, number to number, duration to time, fontWeight to number (keywords such as bold become 700), cubicBezier to easingFunction, shadow to shadow. fontFamily, strokeStyle and the other composite types (border, transition, gradient, typography) are an error. A value is a CSS string of the type's grammar, or the DTCG form: { colorSpace, components, alpha? }, { value, unit } (px or rem, ms or s), a number, [x1, y1, x2, y2] (cubic-bezier(x1, y1, x2, y2)), { color, offsetX, offsetY, blur, spread, inset? } or an array of them (the parts are DTCG values or CSS strings, without references). The initial value follows the rule of "Tokens": { value: 1, unit: "rem" } is initial-value:16px and :root{--space-md:1rem}.--color-bg). A second argument to createTokens maps a path (an array of names) to a name, or to { var, inherit }.token.<type>() and of a createTokens() leaf, an override of createGlobalTheme() (its references replaced by their literals) and a token.set() value. It is checked as a value of a property that takes its type (color for a colour, width for a length, transform for a transform list; custom-ident and resolution have none), so oklch() warns for a target without it, like color: oklch(...). A warning is given once per token (or theme value) and BCD feature per build, and a dev server gives it again after each edit, as for properties. It names the token path and, for a theme, the theme: createTokens(): color.accent value: "oklch()" in "oklch(0.62 0.19 259)" is not supported by chrome 109 (css.types.color.oklch), createGlobalTheme(): color.accent value in .light: "oklch()" in ..., token.color() initial value of --name: ..., token.set() value of --name: .... An alias has the same warning for its own token, since its @property rule holds the same literal. A value that goes into the sheet gets no warning when a fallback below handles it for the targets (the bullet "No warning for what LightningCSS lowers" below says what LightningCSS lowers); an inline token.set() value never goes through LightningCSS and keeps the warning, as does a value LightningCSS cannot lower (color-mix() over a token in a class).@property rule (oklch() in Chrome 109) drops the rule, and the token has no value at all. When some target lacks a value, the engine writes it for that target (transforming --x:value through LightningCSS with the lacking targets and taking the first declaration, #db4aa7 for oklch(0.637 0.203 345)) and nothing changes for a target set that has it, byte for byte:token.color("oklch(0.637 0.203 345)", "accent"), a createTokens() leaf): @property --accent{…initial-value:#db4aa7} and :root{--accent:oklch(0.637 0.203 345)}, which LightningCSS lowers like any custom property (--accent:#db4aa7, then the wide-gamut lab() under @supports (color: lab(0% 0 0))). A browser that parses the value gets the wide one, so a modern browser reads the same colour as before, written as lab() (:where(*) stands for :root when the token does not inherit).var() (oklch(0.637 0.203 {hue.accent}), color-mix() over a token, {path} references): LightningCSS cannot lower a value with var(). Its default is the lowered literal (the references replaced by the values the tokens start with) and the live value comes after it under @supports of the literal itself, the feature the value needs and no table of features: :root{--accent:#db4aa7} then @supports (color:oklch(0.637 0.203 345)){:root{--accent:oklch(0.637 0.203 var(--hue-accent))}}. A browser that parses the literal reads the live value, so the hue slider works; one that does not keeps the default, unless the runtime of the next bullet computes the value. A theme does the same inside its own rule, @supports (…){@media (…){:root{…}}} or @supports (…){.dark{…}}, after the default of that theme. An alias ({color.accent} as the whole value) stays live, since it needs no feature of its own, and reads the default of its target. A theme that sets a token a derived token depends on declares that derived token again (live, as above), and an older browser keeps the default of the derived token there.apps/sky/test/old-browser.mjs: Mu pink in real colours, light and dark, before the runtime of the next bullet moves anything) and Chrome 154 (the colours stay oklch() and follow the slider). The cost on sky is one more :root declaration per token and one @supports rule per derived value: 27.97 kB to 29.58 kB of CSS with the default targets.oklch(0.637 0.203 var(--hue-accent)), lab(from color(from var(--color-accent) srgb-linear …) …)), the slider would do nothing. The engine then ships a small browser module, cssints/derived, that computes the live values in JavaScript. Tokens are not members, so this is not a plugin you import: the engine registers the runtime itself when a derived colour needs it, and delivers it the way it delivers a plugin's runtime (virtual:cssints/runtime/derived, empty, export {};, unless a browserslist target lacks a feature the literals need and has @property; the same needed() decision). The client modules that use such a token import it. With targets that parse every value nothing is written or shipped: sky built for chrome 154 is byte-identical to a build without the runtime.:root in layer _.k (--_derived, JSON in a string) with only what the sheet uses: p, the literals a browser must parse for the runtime to stay idle (the same literals as the @supports tests); b, the template of each derived colour of the default theme (oklch(0.637 0.203 var(--hue-accent))); t, per theme in sheet order, its condition (a selector, or @media (…)) and the templates it sets, 0 for a token it sets to a literal. A token that a theme overrides with a plain {path} alias stays live and is released by the runtime.document, and nothing when the browser parses every p (Chrome 154 gets the same CSS as an old one and writes nothing on <html>). Otherwise it picks the themes that apply to <html> (matches() of the selector, matchMedia() of the condition), evaluates the templates over the computed values of the inputs (--hue-accent and any other token a template reads; the runtime's own results are used as they are, not read back), and writes the results as inline custom properties on <html>, as rgb(). It runs again on any attribute change of <html> (class, style: the slider, the theme classes) and when a theme's media query changes (prefers-color-scheme), and once the stylesheet has loaded if it was not there at the start. It reads every input before the first write, so one input costs one style recalculation. A token it cannot compute at the moment (an input is missing) keeps its static default.rgb()/rgba(), oklch(), oklab(), lab(), color(srgb | srgb-linear …), color-mix() in srgb, srgb-linear, oklab or lab (shares that add up to 100%), the names black, white and transparent; relative colour (from) with the channel keywords, numbers, percentages, deg, + - * /, parentheses, calc(), clamp(), min(), max() and var(). A colour outside sRGB is clipped to it (an old browser has no wider gamut). Anything else (light-dark(), hsl(), a polar color-mix(), a wide-gamut color(), another unit), a derived token that is not a colour, one that does not inherit, and a value in a container() theme stays at its static default, and the build warns, naming the token and the target: tf.color.mixed: "color-mix(in oklch, …)" stays at its static default in chrome 109: the runtime for derived tokens does not evaluate "oklch". The themes it reads are those of <html> (:root, a selector that matches it, a media query), not of an element inside the page. A template should read plain tokens and derived tokens, not an alias of a derived token (it would be read one update late).cssints/derived is 7.2 kB minified, 3.1 kB gzipped; sky's CSS grows by the data (29.6 kB to 31.4 kB with the default targets, about 0.6 kB gzipped). The colours of the default theme take 10 µs of JavaScript per input; in Chromium 109 a slider input costs 1.2 ms against 0.6 ms for the style recalculation alone, which the browser pays on any change of the hue. Checked in apps/sky/test/old-browser.mjs: in Chromium 109 the four accent steps, the label's onAccent and the page background at hues 0, ±90 and ±180 are within 1/255 of the pixels Chrome 154 paints, in light, dim, dark and system under a light and a dark scheme, and the system scheme changing recomputes them; packages/cssints/test/derived-runtime.mjs holds the evaluator to culori (the maths of check.contrast) on the sky templates and random inputs.createGlobalTheme(tokens, condition | selector, overrides, { layer?, scope? }?) re-declares the overridden tokens under a media() condition on :root, or under a selector. Under container() it declares them on :where(*), since :root has no container above it and would never match. layer names a top-level layer for the rule ({ layer: "app" } puts an app look in @layer app, above the engine's :root fallbacks) that layers() has declared, in this module or one it imports: an undeclared layer is a build error at the call. Without layer the rule is in _.k. scope (with a selector) confines the rule to a subtree, @scope (article.post) { [data-mode="hero"] { ... } }, so a foreign look cannot repaint the rest of the page; it is a selector, checked by the build like the one of global() and balanced in the types, and it is an error with a condition (:root is not inside a scope). Overrides are checked against the token types, and an unknown path is a type error; they take the same values as tokens, and tokens may be a group (t.color). supports() and pseudo-classes are not themes: createGlobalTheme(t, hover, …) is a type error, and a build error when the types are bypassed. A module that uses a token gets the theme rules that set it, with the @property rules of the tokens it uses and of those their values refer to, not of every token the theme sets.layers(...names) declares top-level layers in order. The sheet prints @layer app, author, viewer; once, right after the engine's @layer _.k, _.a, …;, however many modules declare it (a module's sheet has the statements of its own layers() calls and of the layers it uses). The same names again are fine; names in another order (layers("viewer", "app") after the one above), or sharing layers without one statement holding the other (layers("viewer", "base")), are a build error at the second call, since the sheet could not say which comes first. A statement that holds another is printed first; statements that share nothing are printed longest first. A name is letters, digits, _ and -.layers(...names, { before: true }) declares them before the engine's: the sheet prints @layer reset; above @layer _.k, _.a, …;, so _.k, the classes and every layer declared after rank above what is in them (a reset that any style beats). The rules above hold among the statements before, in the same order; a layer declared both before and after (layers("reset") once layers("reset", { before: true }) has run, or the other way) is a build error at the second call. A stylesheet's own layer goes between a reset and cssints with layers("reset", "base", { before: true }).import * as import csscss from "cssints" with { type: "cssints" };
import csscss.const layers: (...names: readonly [string, ...string[]] | readonly [string, ...string[], {
readonly before: boolean;
}]) => void
Declares top-level layers in order, printed once after the engine's own (`@layer app, author, viewer;`), so what is in
them beats the engine's `:root` fallbacks; `{ before: true }` at the end prints them before the engine's, below every
class (`layers("reset", { before: true })`). A theme's `layer` and a plugin's rules must name a declared layer. The
same names again are fine; the same names in another order, or both before and after, are a build error.layers("app", "author", "viewer");
const const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
t = import csscss.const createTokens: <{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>(tokens: {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
} & ValidGroup<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, name?: (path: readonly string[]) => string | TokenName) => css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
Tokens from an inline DTCG-shaped `const` object: `$type` is inherited through groups, a leaf is `{ $value }`, a value is
a DTCG value or a CSS string of the type's grammar, an alias is `"{group.token}"`. The variable is the kebab-case path
(`--color-bg`), or what the mapper returns for the path.createTokens({ color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
} & ValidGroup<{
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
color: { $type: "color"$type: "color", bg: {
readonly $value: "#fff";
}
bg: { $value: "#fff"$value: "#fff" } } });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly color: {
readonly bg: "#000";
};
}, string>(tokens: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, condition: css.QueryWrap | string, overrides: {
readonly color: {
readonly bg: "#000";
};
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
t, '[data-mode="dark"]', { color: {
readonly bg: "#000";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly bg: "#000";
}, css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>>
color: { bg: "#000"bg: "#000" } }, { layer?: string | undefinedlayer: "viewer" });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly color: {
readonly bg: "#123";
};
}, "article.post">(tokens: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, condition: css.QueryWrap | string, overrides: {
readonly color: {
readonly bg: "#123";
};
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
t, '[data-mode="hero"]', { color: {
readonly bg: "#123";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly bg: "#123";
}, css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>>
color: { bg: "#123"bg: "#123" } }, { layer?: string | undefinedlayer: "author", scope?: "article.post" | undefinedscope: "article.post" });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly color: {
readonly bg: "#000";
};
}, "a[href">(tokens: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, condition: css.QueryWrap | string, overrides: {
readonly color: {
readonly bg: "#000";
};
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>
t, ".x", { color: {
readonly bg: "#000";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>, {
readonly bg: "#000";
}, css.Tokens<{
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly bg: {
readonly $value: "#fff";
};
};
}>>
color: { bg: "#000"bg: "#000" } }, { scope: "a[href" }); // error: unbalanced brackets in the scopecss.layers(); // error: a declaration has a nameimport csscss.const layers: (...names: readonly [string, ...string[]] | readonly [string, ...string[], {
readonly before: boolean;
}]) => void
Declares top-level layers in order, printed once after the engine's own (`@layer app, author, viewer;`), so what is in
them beats the engine's `:root` fallbacks; `{ before: true }` at the end prints them before the engine's, below every
class (`layers("reset", { before: true })`). A theme's `layer` and a plugin's rules must name a declared layer. The
same names again are fine; the same names in another order, or both before and after, are a build error.layers("reset", { before: booleanbefore: true }); // @layer reset; before @layer _.k, _.a, …;t.color.base is Token<"color", true, "#545434"> on hover. An alias carries its reference ("{color.base}": a theme can change the base), a number or { value, unit } its CSS text ("150ms"), a DTCG colour object and anything from a JSON import ($value widens to string there) string. It is the :root definition, not what a theme shows. A Token<K, S, V> fits wherever a Token<K> does._ and the key: "2xs" in the data is t.space._2xs in code, and the overrides of a theme follow the set ({ space: { _2xs: "3px" } }). The variable (--space-2xs), references ({space.2xs}) and the DTCG data keep the key; 2xs and _2xs in one group is a build error.@property initial-value must be computationally independent, so it gets the flattened literal. The alias stays live as a var() declaration on :root. A theme re-declares the aliases that depend on an overridden token (all of them, through chains), since var() is substituted where it is declared. A {path} must name a token of the same $type; a cycle is an error.$value may refer to other tokens inside a CSS value, "color-mix(in oklab, {color.accent}, black 15%)" or "calc({space.md} * 2)". It stays live CSS: the @property initial value takes the targets' literals, the :root declaration keeps var(--color-accent), and a theme that sets color.accent declares every token derived from it again (through chains), so a hover colour follows the brand colour. A derived token needs its $type (or its group's); in the editor its value is checked as the type's grammar with each {path} in place as a value of that token's type, so a missing path or a value that is not of the type is a type error.import * as import csscss from "cssints" with { type: "cssints" };
export const const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>
t = import csscss.const createTokens: <{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>(tokens: {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
} & ValidGroup<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>, name?: (path: readonly string[]) => string | TokenName) => css.Tokens<...>
Tokens from an inline DTCG-shaped `const` object: `$type` is inherited through groups, a leaf is `{ $value }`, a value is
a DTCG value or a CSS string of the type's grammar, an alias is `"{group.token}"`. The variable is the kebab-case path
(`--color-bg`), or what the mapper returns for the path.createTokens({
color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
} & ValidGroup<{
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>
color: {
$type: "color"$type: "color",
accent: {
readonly $value: "#2563eb";
}
accent: { $value: "#2563eb"$value: "#2563eb" },
hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
}
hover: { $value: "color-mix(in oklab, {color.accent}, black 15%)"$value: "color-mix(in oklab, {color.accent}, black 15%)" },
},
});
import csscss.const createGlobalTheme: <css.Tokens<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>, {
readonly color: {
readonly accent: "#db2777";
};
}, string>(tokens: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>, condition: css.QueryWrap | string, overrides: {
readonly color: {
readonly accent: "#db2777";
};
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>
t, ".brand", { color: {
readonly accent: "#db2777";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
}, "color", {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>, {
readonly accent: "#db2777";
}, css.Tokens<{
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}, undefined, {
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "#2563eb";
};
readonly hover: {
readonly $value: "color-mix(in oklab, {color.accent}, black 15%)";
};
};
}>>
color: { accent: "#db2777"accent: "#db2777" } }); // hover follows{path} too, as the whole value ("{radius.sm}") or inside a CSS value ("oklch(0.7 0.1 {hue.accent})"). The theme declares var(--target), so the value is live; tokens derived from the overridden token are declared again as above. Order does not matter: the declarations of one rule belong to one element, and a var() reads that element's own value of the target, so a theme that sets hue.accent and a colour made of it needs no particular order. A reference to no token, a whole-value reference to a token of another type, a value that is not of the token's type with each reference replaced by its target's value (a literal at build time, a value of the target's type in the editor), and a cycle through the base tokens and the theme are errors. Paths are from the root of the tokens, so give the root (t) to a theme that refers to another group; the editor rejects a reference outside the group it is given.import * as import csscss from "cssints" with { type: "cssints" };
export const const t: css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
t = import csscss.const createTokens: <{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>(tokens: {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
} & ValidGroup<...>, name?: (path: readonly string[]) => string | TokenName) => css.Tokens<...>
Tokens from an inline DTCG-shaped `const` object: `$type` is inherited through groups, a leaf is `{ $value }`, a value is
a DTCG value or a CSS string of the type's grammar, an alias is `"{group.token}"`. The variable is the kebab-case path
(`--color-bg`), or what the mapper returns for the path.createTokens({
hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
} & ValidGroup<{
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
}, "number", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
hue: { $type: "number"$type: "number", accent: {
readonly $value: 345;
}
accent: { $value: 345$value: 345 } },
radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
} & ValidGroup<{
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
}, "dimension", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
radius: { $type: "dimension"$type: "dimension", sm: {
readonly $value: "4px";
}
sm: { $value: "4px"$value: "4px" }, md: {
readonly $value: "8px";
}
md: { $value: "8px"$value: "8px" } },
color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
} & ValidGroup<{
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
}, "color", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
color: { $type: "color"$type: "color", accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
}
accent: { $value: "oklch(0.6 0.2 {hue.accent})"$value: "oklch(0.6 0.2 {hue.accent})" } },
});
import csscss.const createGlobalTheme: <css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
t, ".square", { radius: {
readonly md: "{radius.sm}";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
}, "dimension", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
readonly md: "{radius.sm}";
}, css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>>
radius: { md: "{radius.sm}"md: "{radius.sm}" } });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
t, ".dim", { hue: {
readonly accent: 12;
} & css.CheckOverrides<css.Tokens<{
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
}, "number", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
readonly accent: 12;
}, css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>>
hue: { accent: 12accent: 12 }, color: {
readonly accent: "oklch(0.7 0.1 {hue.accent})";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
}, "color", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
readonly accent: "oklch(0.7 0.1 {hue.accent})";
}, css.Tokens<...>>
color: { accent: "oklch(0.7 0.1 {hue.accent})"accent: "oklch(0.7 0.1 {hue.accent})" } });
import csscss.const createGlobalTheme: <css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
...;
}, string>(tokens: css.Tokens<...>, condition: css.QueryWrap | string, overrides: {
...;
} & css.CheckOverrides<...>, options?: {
...;
} | undefined) => void
Re-declares the overridden tokens under a media or container condition (on `:root`), or under a selector, and the
aliases that depend on them. An unknown path and a value that is not of the token's type are type errors.
`layer` puts the rule in a top-level layer that `layers()` declares (the build checks that it does); `scope` (with a
selector) confines it to a subtree: `@scope (<scope>) { ... }`.createGlobalTheme(const t: css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>
t, ".x", { radius: {
readonly md: "{hue.accent}";
} & css.CheckOverrides<css.Tokens<{
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
}, "dimension", {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>, {
readonly md: "{hue.accent}";
}, css.Tokens<{
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}, undefined, {
readonly hue: {
readonly $type: "number";
readonly accent: {
readonly $value: 345;
};
};
readonly radius: {
readonly $type: "dimension";
readonly sm: {
readonly $value: "4px";
};
readonly md: {
readonly $value: "8px";
};
};
readonly color: {
readonly $type: "color";
readonly accent: {
readonly $value: "oklch(0.6 0.2 {hue.accent})";
};
};
}>>
radius: { md: "{hue.accent}" } }); // error: a number, not a lengthcreateTokens takes a DTCG file imported as JSON, import tokens from "./tokens.json" with { type: "json" }. The editor knows the tree (t.color.bg, and a wrong path is a type error) but not the types, since a JSON import widens $type to string: each token is a token of any type there, and its values, references and use in a property (and in check.contrast) are checked at build time.createGlobalTheme(t, dark, darkJson) takes { $value } leaves and skips $type, $description and $extensions (com.figma.*, the root's com.figma.modeName); a key that starts with a digit (500) is the set's _500. A theme declares every token of the file, the unchanged ones too. Figma writes a FLOAT variable as a number token (5), which a length property does not take: calc(t.radius, "*", "1px"), or $type: "dimension" with a { value, unit } in the file. A colour is { colorSpace: "srgb", components, alpha, hex }, read as color(srgb …).$extensions.mode are not read: with "Split modes into separate files" each mode is a file, as above. Each file has the collection as its top-level key and refers across collections by it ({Primitives.color.blue}), so the files of all collections go into one createTokens: createTokens({ ...primitives, ...semantic }).value and type without $, its own types (spacing, fontSizes, borderRadius, boxShadow, …), unitless dimensions, math ({spacing.base} * 2) and colour modifiers in $extensions. Style Dictionary with @tokens-studio/sd-transforms resolves all of that; a format of six lines writes the result as DTCG, which createTokens takes (checked with style-dictionary 5.6 and sd-transforms 2.0; the aliases are resolved to their values, and a theme is a second build over the sets of a theme of $themes.json):import StyleDictionary from "style-dictionary";
import { register } from "@tokens-studio/sd-transforms";
register(StyleDictionary);
const DTCG = { fontSize: "dimension", lineHeight: "number", opacity: "number" }; // the types sd-transforms leaves
StyleDictionary.registerFormat({
name: "cssints/dtcg",
format: ({ dictionary }) => {
const out = {};
for (const t of dictionary.allTokens) {
let group = out;
for (const key of t.path.slice(0, -1)) group = group[key] ??= {};
const type = t.$type ?? t.type;
group[t.path.at(-1)] = { $type: DTCG[type] ?? type, $value: t.$value ?? t.value };
}
return JSON.stringify(out, null, 2);
},
});
await new StyleDictionary({
source: ["tokens/**/*.json"],
preprocessors: ["tokens-studio"],
platforms: { cssints: { transformGroup: "tokens-studio", files: [{ destination: "tokens.json", format: "cssints/dtcg" }] } },
}).buildAllPlatforms();value/type without $ (global.Main.0 has value and type without $, the legacy format of Tokens Studio …), $themes or $metadata in the tree, a Tokens Studio type (the error names the DTCG type: "spacing" is a Tokens Studio type: its DTCG type is "dimension"), math outside calc() (write "calc({spacing.base} * 2)"), a Tokens Studio colour modifier ($extensions["studio.tokens"].modify), a Figma boolean (com.figma.type: "boolean" on a number), and more than one mode in $extensions (mode, or modes of com.figma). string, boolean, fontFamily and the composite types are errors as before (no token type), so leave them out of the file (Figma: a collection without them; TokensBrücke: no styles). Samples of each tool are in packages/cssints/test/fixtures/importers._.k, after the global rules of css.global() and before the class layers. They set custom properties only, and no class does, so the layer order never decides between them; _.k is the lowest layer, so your own unlayered --color-bg rule wins over a theme. The :root rules of aliases come first, then themes under a condition, then themes under a selector, each in source order, so a selector theme beats a condition theme on the same element. A module has the rules of the tokens it uses, from wherever they were made, and of the tokens those are made of (the references of a derived token or of a theme value, through chains: a hue.accent that no class uses still gets its @property rule), and its own; import a theme module (import "./theme.ts") to have all of it.css.check.contrast(fg, bg, { min }) computes the WCAG 2.x contrast ratio (min from 1 to 21) for the default values and for every theme that sets either token or one they are aliases of. It reads themes one at a time, except those of one selector: themes with the same selector (and scope) meet on one element, so they are read together, laid over each other in the order of the cascade (no layer first, then the declared layers in order, then source order). A viewer look that sets only the text colour is checked on the background of the app look under the same selector. Themes of different selectors, or a selector and a condition, are still read one at a time, not in their combinations. A value that is set at run time (a slider that sets --hue-accent on <html>) belongs to no theme and is checked at its default only; a theme per value would put each rule in the sheet and hold it to the thresholds of the other themes, since a check applies to every theme that touches its tokens, so measure a range outside the build (apps/sky test/contrast.mjs). A ratio below min is a build error that names the theme and both resolved values (the ratio is cut, not rounded: 4.499 is 4.49). A value the check cannot evaluate (color-mix(), a relative colour, light-dark(), currentColor, a system colour) or a translucent one is a warning that names the token; a build says it once, and a dev server says it again after each edit. A derived token (or a theme value with {path} references) is read in each theme by putting that theme's values, or the defaults, in place of its references, through a chain of derived tokens: a ratio when the result is a colour (oklch(0.6 0.2 {hue.accent})), a warning that names the theme when it is not (color-mix() over another token), and a theme that sets any token a checked colour depends on, directly, through an alias or through references, is checked. The colour library (culori, culori/fn: 27 kB minified, 9 kB gzipped) is build-only and never ships. The check runs when its module has run, and again at the end of a build over the themes of every module.Output (the @property rules of space-md and color-fg are not shown):
@layer _.k, _.a, _.b, _.c, _.d, _.e;
@property --color-accent { syntax: "<color>"; inherits: true; initial-value: oklch(62% 0.19 259); }
@property --color-bg { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
@property --color-link { syntax: "<color>"; inherits: true; initial-value: oklch(62% 0.19 259); }
@layer _.k {
:root { --color-link: var(--color-accent); }
@media (prefers-color-scheme: dark) {
:root { --color-bg: #0b0b0f; --color-fg: #f3f4f6; }
}
@container (width < 30rem) {
:where(*) { --color-bg: #eee; }
}
.light { --color-bg: #fff; }
}Derived tokens (contrastColor(), derive()), JSON input with generated types and slot variants are not part of 0.1.