Tokens

A token is a Typed OM value whose toString() is var(--name). It fits anywhere a value of its type fits: color(blue), border("1px solid", blue). In math and in other CSS functions it is a part of a call: calc(t.space.md, "*", 2), var(t.space.sm, "4px") (see "Functions").

import * as import csscss from "cssints" with { type: "cssints" };

const const blue: Token<"color", true, string>blue = import csscss.
const token: {
    readonly number: TokenFn<"number">;
    readonly color: TokenFn<"color">;
    readonly length: TokenFn<"length">;
    readonly percentage: TokenFn<"percentage">;
    readonly integer: TokenFn<"integer">;
    readonly angle: TokenFn<"angle">;
    readonly time: TokenFn<"time">;
    readonly resolution: TokenFn<"resolution">;
    readonly url: TokenFn<"url">;
    readonly image: TokenFn<"image">;
    readonly shadow: TokenFn<"shadow">;
    readonly lengthPercentage: TokenFn<"lengthPercentage">;
    readonly customIdent: TokenFn<...>;
    readonly transformList: TokenFn<...>;
    readonly easingFunction: TokenFn<...>;
} & {
    ...;
}
`token.<type>(initial, name?)`: a Typed OM value of the type, `var(--name)`. With a name it can be set.
token
.color: <"blue", "color-primary">(initial: "blue", name?: "color-primary" | undefined) => Token<"color", true, string>color("blue", "color-primary"); // --color-primary, can be set
const const gap: Token<"length", true, string>gap = import csscss.
const token: {
    readonly number: TokenFn<"number">;
    readonly color: TokenFn<"color">;
    readonly length: TokenFn<"length">;
    readonly percentage: TokenFn<"percentage">;
    readonly integer: TokenFn<"integer">;
    readonly angle: TokenFn<"angle">;
    readonly time: TokenFn<"time">;
    readonly resolution: TokenFn<"resolution">;
    readonly url: TokenFn<"url">;
    readonly image: TokenFn<"image">;
    readonly shadow: TokenFn<"shadow">;
    readonly lengthPercentage: TokenFn<"lengthPercentage">;
    readonly customIdent: TokenFn<...>;
    readonly transformList: TokenFn<...>;
    readonly easingFunction: TokenFn<...>;
} & {
    ...;
}
`token.<type>(initial, name?)`: a Typed OM value of the type, `var(--name)`. With a name it can be set.
token
.
length: <"16px", {
    readonly var: "gap";
    readonly inherit: false;
}>(initial: "16px", name?: {
    readonly var: "gap";
    readonly inherit: false;
} | undefined) => Token<"length", true, string>
length
("16px", { var: "gap"var: "gap", inherit: falseinherit: false });
const const muted: Token<"color", false, string>muted = import csscss.
const token: {
    readonly number: TokenFn<"number">;
    readonly color: TokenFn<"color">;
    readonly length: TokenFn<"length">;
    readonly percentage: TokenFn<"percentage">;
    readonly integer: TokenFn<"integer">;
    readonly angle: TokenFn<"angle">;
    readonly time: TokenFn<"time">;
    readonly resolution: TokenFn<"resolution">;
    readonly url: TokenFn<"url">;
    readonly image: TokenFn<"image">;
    readonly shadow: TokenFn<"shadow">;
    readonly lengthPercentage: TokenFn<"lengthPercentage">;
    readonly customIdent: TokenFn<...>;
    readonly transformList: TokenFn<...>;
    readonly easingFunction: TokenFn<...>;
} & {
    ...;
}
`token.<type>(initial, name?)`: a Typed OM value of the type, `var(--name)`. With a name it can be set.
token
.color: <"#6b7280", undefined>(initial: "#6b7280", name?: undefined) => Token<"color", false, string>color("#6b7280"); // --_<hash>, private
export const const A: () => anyA = () => <IntrinsicElements[string]: anydiv className?: string | undefinedclassName={import csscss.const cn: (...styles: css.Style[]) => css.Stylecn(import csscss.const color: <readonly [Token<"color", true, string>]>(parts_0: Token<"color", true, string>) => 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 blue: Token<"color", true, string>blue), import csscss.const gap: <readonly [Token<"length", true, string>]>(parts_0: Token<"length", true, string>) => css.Style
`<'row-gap'> <'column-gap'>?`. Chrome 57, Edge 16, Firefox 52, Safari 10.1, iOS 10.3, Android 57. [MDN](https://developer.mozilla.org/docs/Web/CSS/gap)
gap
(const gap: Token<"length", true, string>gap), import csscss.const color: <readonly [Token<"color", false, string>]>(parts_0: Token<"color", false, string>) => 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 muted: Token<"color", false, string>muted))} />;
export const const B: () => anyB = () => <IntrinsicElements[string]: anydiv style?: Record<string, string> | undefinedstyle={import csscss.const style: (...styles: (css.Style | StyleObject)[]) => StyleObject
css values (declarations, no conditions) and `token.set()` results, as an inline `style` object.
style
(import csscss.const color: <readonly [Token<"color", true, string>]>(parts_0: Token<"color", true, string>) => 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 blue: Token<"color", true, string>blue), import csscss.
const token: {
    readonly number: TokenFn<"number">;
    readonly color: TokenFn<"color">;
    readonly length: TokenFn<"length">;
    readonly percentage: TokenFn<"percentage">;
    readonly integer: TokenFn<"integer">;
    readonly angle: TokenFn<"angle">;
    readonly time: TokenFn<"time">;
    readonly resolution: TokenFn<"resolution">;
    readonly url: TokenFn<"url">;
    readonly image: TokenFn<"image">;
    readonly shadow: TokenFn<"shadow">;
    readonly lengthPercentage: TokenFn<"lengthPercentage">;
    readonly customIdent: TokenFn<...>;
    readonly transformList: TokenFn<...>;
    readonly easingFunction: TokenFn<...>;
} & {
    ...;
}
`token.<type>(initial, name?)`: a Typed OM value of the type, `var(--name)`. With a name it can be set.
token
.set: <"color", "red">(token: Token<"color", true, string>, value: "red") => StyleObjectset(const blue: Token<"color", true, string>blue, "red"))} />; // { "--color-primary": "red", color: "var(--color-primary)" }
import csscss.
const token: {
    readonly number: TokenFn<"number">;
    readonly color: TokenFn<"color">;
    readonly length: TokenFn<"length">;
    readonly percentage: TokenFn<"percentage">;
    readonly integer: TokenFn<"integer">;
    readonly angle: TokenFn<"angle">;
    readonly time: TokenFn<"time">;
    readonly resolution: TokenFn<"resolution">;
    readonly url: TokenFn<"url">;
    readonly image: TokenFn<"image">;
    readonly shadow: TokenFn<"shadow">;
    readonly lengthPercentage: TokenFn<"lengthPercentage">;
    readonly customIdent: TokenFn<...>;
    readonly transformList: TokenFn<...>;
    readonly easingFunction: TokenFn<...>;
} & {
    ...;
}
`token.<type>(initial, name?)`: a Typed OM value of the type, `var(--name)`. With a name it can be set.
token
.set: <"color", "red">(token: Token<"color", true, string>, value: "red") => StyleObjectset(muted, "red"); // error: private tokens cannot be set
Argument of type 'Token<"color", false, string>' is not assignable to parameter of type 'Token<"color", true, string>'. Type 'false' is not assignable to type 'true'.
@property --color-primary {
	syntax: "<color>";
	inherits: true;
	initial-value: blue;
}