Tokens

Pick a primary and a secondary colour. You get a token set that survives a rebrand: three layers, light and dark, contrast already checked. Free, CC0. It runs in your browser and sends nothing anywhere.

Why three layers? The note explains.

1. Your colours

Primary · the main action

Secondary · the second level, optional

2. Neutrals

What I changed

  • secondary: #ff5a28 became #e03400, so white text on a button reaches 4.5:1. Hue and saturation stay.

3. Your palette

Click a colour to copy its hex.

primary

secondary

neutral · warm

4. In use

A small made-up shop. It knows no hex value, only the semantic colours: primary for the main action, secondary for the second level.

New roast

Coffee that arrives before you run out.

Small batches, roasted on Monday, at your door by Thursday. Pause or skip any time.

Pick your beans

Ember Blend

Dark, cocoa, toasted almond

12 €
Moss Origin

Bright, green apple, honey

14 €
Night Shift

Decaf, caramel, hazelnut

13 €

Never run out

Choose how often. Free shipping from 25 €.

12,00 € per bag, every four weeks

© Lantern Roasters (made up)Try Tab: the focus ring is the text colour.

5. Contrast

All 16 pairs pass. Text needs 4.5:1 (WCAG AA), button edges 3:1. "AAA" means 7:1 or more.

light

  • Aa Sample text

    Body text

    16.61:1 AAA

  • Aa Sample text

    Text on cards

    15.26:1 AAA

  • Aa Sample text

    Button text

    6.15:1 AA

  • Aa Sample text

    Button hover

    9.31:1 AAA

  • Aa Sample text

    Links and edges

    5.85:1 AA

  • Aa Sample text

    Secondary button

    4.51:1 AA

  • Aa Sample text

    Secondary hover

    6.54:1 AA

  • Aa Sample text

    Secondary edge

    4.28:1 AA

dark

  • Aa Sample text

    Body text

    15.81:1 AAA

  • Aa Sample text

    Text on cards

    13.04:1 AAA

  • Aa Sample text

    Button text

    16.14:1 AAA

  • Aa Sample text

    Button hover

    18.47:1 AAA

  • Aa Sample text

    Links and edges

    16.14:1 AAA

  • Aa Sample text

    Secondary button

    15.54:1 AAA

  • Aa Sample text

    Secondary hover

    18.47:1 AAA

  • Aa Sample text

    Secondary edge

    15.54:1 AAA

6. Take it with you

Already have a stylesheet? Audit it and see which colours are the same twice. Built a component? Stress-test it.

The kit has your tokens, the build script, a layer lint, the contrast check, a Tailwind preset and an example page. CC0, no sign-up. Then: node build-tokens.mjs, node lint-tokens.mjs, node check-contrast.mjs.

Look at tokens.css
/* uxe.works token kit. Generated by build-tokens.mjs from tokens.json. Edit tokens.json, not this file. */
:root {
  --color-primary-100: #e8f2ec;
  --color-primary-500: #3d6b4f;
  --color-primary-600: #2c4e39;
  --color-secondary-100: #f5e9e5;
  --color-secondary-500: #e03400;
  --color-secondary-600: #b22900;
  --color-neutral-0: #ffffff;
  --color-neutral-50: #fbf9f4;
  --color-neutral-100: #f1ede4;
  --color-neutral-850: #26261e;
  --color-neutral-900: #1a1a14;
  --color-neutral-950: #14140f;
  --radius-sm: 4px;
  --radius-md: 8px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --duration-fast: 120ms;
  --duration-base: 200ms;
}

:root {
  --button-background: var(--action);
  --button-background-hover: var(--action-hover);
  --button-text: var(--on-action);
  --button-radius: var(--radius-md);
  --button-padding: var(--space-3) var(--space-4);
  --button-transition: var(--duration-base);
  --card-background: var(--subtle);
  --card-text: var(--text);
  --card-radius: var(--radius-md);
  --button-secondary-background: var(--secondary);
  --button-secondary-background-hover: var(--secondary-hover);
  --button-secondary-text: var(--on-secondary);
  --button-secondary-radius: var(--radius-md);
  --button-secondary-padding: var(--space-3) var(--space-4);
  --button-secondary-transition: var(--duration-base);
  --badge-background: var(--secondary);
  --badge-text: var(--on-secondary);
  --badge-radius: var(--radius-sm);
}

/* Light */
:root {
  color-scheme: light;
  --surface: var(--color-neutral-50);
  --text: var(--color-neutral-900);
  --action: var(--color-primary-500);
  --action-hover: var(--color-primary-600);
  --on-action: var(--color-neutral-0);
  --subtle: var(--color-primary-100);
  --secondary: var(--color-secondary-500);
  --secondary-hover: var(--color-secondary-600);
  --on-secondary: var(--color-neutral-0);
}

/* Dark: the system decides, unless the page chose a side. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --surface: var(--color-neutral-950);
    --text: var(--color-neutral-100);
    --action: var(--color-primary-100);
    --action-hover: var(--color-neutral-0);
    --on-action: var(--color-neutral-950);
    --subtle: var(--color-neutral-850);
    --secondary: var(--color-secondary-100);
    --secondary-hover: var(--color-neutral-0);
    --on-secondary: var(--color-neutral-950);
  }
}

/* Dark: chosen explicitly. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --surface: var(--color-neutral-950);
  --text: var(--color-neutral-100);
  --action: var(--color-primary-100);
  --action-hover: var(--color-neutral-0);
  --on-action: var(--color-neutral-950);
  --subtle: var(--color-neutral-850);
  --secondary: var(--color-secondary-100);
  --secondary-hover: var(--color-neutral-0);
  --on-secondary: var(--color-neutral-950);
}
Look at tokens.json
{
  "$description": "uxe.works token kit, generated at uxe.works/tokens. Three layers. Primitives are raw values. Semantic tokens say what a value is for. Component tokens say where it is used. Components only ever read the last layer. Format follows the W3C Design Tokens draft ($value, $type).",
  "primitive": {
    "color": {
      "primary": {
        "100": {
          "$value": "#e8f2ec",
          "$type": "color"
        },
        "500": {
          "$value": "#3d6b4f",
          "$type": "color"
        },
        "600": {
          "$value": "#2c4e39",
          "$type": "color"
        }
      },
      "secondary": {
        "100": {
          "$value": "#f5e9e5",
          "$type": "color"
        },
        "500": {
          "$value": "#e03400",
          "$type": "color"
        },
        "600": {
          "$value": "#b22900",
          "$type": "color"
        }
      },
      "neutral": {
        "0": {
          "$value": "#ffffff",
          "$type": "color"
        },
        "50": {
          "$value": "#fbf9f4",
          "$type": "color"
        },
        "100": {
          "$value": "#f1ede4",
          "$type": "color"
        },
        "850": {
          "$value": "#26261e",
          "$type": "color"
        },
        "900": {
          "$value": "#1a1a14",
          "$type": "color"
        },
        "950": {
          "$value": "#14140f",
          "$type": "color"
        }
      }
    },
    "radius": {
      "sm": {
        "$value": "4px",
        "$type": "dimension"
      },
      "md": {
        "$value": "8px",
        "$type": "dimension"
      }
    },
    "space": {
      "2": {
        "$value": "8px",
        "$type": "dimension"
      },
      "3": {
        "$value": "12px",
        "$type": "dimension"
      },
      "4": {
        "$value": "16px",
        "$type": "dimension"
      }
    },
    "duration": {
      "fast": {
        "$value": "120ms",
        "$type": "duration"
      },
      "base": {
        "$value": "200ms",
        "$type": "duration"
      }
    }
  },
  "semantic": {
    "light": {
      "surface": {
        "$value": "{primitive.color.neutral.50}"
      },
      "text": {
        "$value": "{primitive.color.neutral.900}"
      },
      "action": {
        "$value": "{primitive.color.primary.500}"
      },
      "action-hover": {
        "$value": "{primitive.color.primary.600}"
      },
      "on-action": {
        "$value": "{primitive.color.neutral.0}"
      },
      "subtle": {
        "$value": "{primitive.color.primary.100}"
      },
      "secondary": {
        "$value": "{primitive.color.secondary.500}"
      },
      "secondary-hover": {
        "$value": "{primitive.color.secondary.600}"
      },
      "on-secondary": {
        "$value": "{primitive.color.neutral.0}"
      }
    },
    "dark": {
      "surface": {
        "$value": "{primitive.color.neutral.950}"
      },
      "text": {
        "$value": "{primitive.color.neutral.100}"
      },
      "action": {
        "$value": "{primitive.color.primary.100}"
      },
      "action-hover": {
        "$value": "{primitive.color.neutral.0}"
      },
      "on-action": {
        "$value": "{primitive.color.neutral.950}"
      },
      "subtle": {
        "$value": "{primitive.color.neutral.850}"
      },
      "secondary": {
        "$value": "{primitive.color.secondary.100}"
      },
      "secondary-hover": {
        "$value": "{primitive.color.neutral.0}"
      },
      "on-secondary": {
        "$value": "{primitive.color.neutral.950}"
      }
    }
  },
  "component": {
    "button": {
      "background": {
        "$value": "{semantic.action}"
      },
      "background-hover": {
        "$value": "{semantic.action-hover}"
      },
      "text": {
        "$value": "{semantic.on-action}"
      },
      "radius": {
        "$value": "{primitive.radius.md}"
      },
      "padding": {
        "$value": "{primitive.space.3} {primitive.space.4}"
      },
      "transition": {
        "$value": "{primitive.duration.base}"
      }
    },
    "card": {
      "background": {
        "$value": "{semantic.subtle}"
      },
      "text": {
        "$value": "{semantic.text}"
      },
      "radius": {
        "$value": "{primitive.radius.md}"
      }
    },
    "button-secondary": {
      "background": {
        "$value": "{semantic.secondary}"
      },
      "background-hover": {
        "$value": "{semantic.secondary-hover}"
      },
      "text": {
        "$value": "{semantic.on-secondary}"
      },
      "radius": {
        "$value": "{primitive.radius.md}"
      },
      "padding": {
        "$value": "{primitive.space.3} {primitive.space.4}"
      },
      "transition": {
        "$value": "{primitive.duration.base}"
      }
    },
    "badge": {
      "background": {
        "$value": "{semantic.secondary}"
      },
      "text": {
        "$value": "{semantic.on-secondary}"
      },
      "radius": {
        "$value": "{primitive.radius.sm}"
      }
    }
  }
}