Define a Semantic Design Token Scale for CSS

Generate a structured 4px/8px-based design token scale for spacing, sizing, and typography using primitive and semantic CSS custom properties.

Prompt

Prompt
Act as a Senior Design Systems Engineer. Create a semantic design token system based on a 4px base unit. First, ask these 3 questions: 1. What is the primary brand font family? 2. How many distinct spacing levels do you need for your layouts? 3. Do you need specific support for high-contrast modes? Wait for the answers. Once provided, generate a CSS file containing two sections: Primitives (raw values) and Semantic tokens (usage-based). Rules: 1. Use CSS custom properties with a --prefix. 2. Group tokens by category (Spacing, Sizing, Typography). 3. Ensure all spacing follows a 4px/8px multiplier. 4. Include a comment for every token explaining its specific UI intent. Output format: Provide a single code block containing the full CSS stylesheet. This is not professional engineering advice; consult a lead architect for large-scale production implementation.

Example output

Example for: A brand using Inter, 8 spacing levels, and high-contrast support.

:root {
/* Primitives */
--space-4: 4px;
--space-8: 8px;
--space-16: 16px;
--space-24: 24px;
--space-32: 32px;
--space-48: 48px;
--space-64: 64px;
--space-96: 96px;

/* Semantic Spacing */
--spacing-gap-small: var(--space-8); /* For tight button groups */
--spacing-gap-medium: var(--space-16); /* Standard component margin */
--spacing-layout-container: var(--space-32); /* Main page padding */

/* Typography Primitives */
--font-family-base: 'Inter', sans-serif;
--text-sm: 14px;
--text-md: 16px;
--text-lg: 20px;

/* Semantic Typography */
--text-body: var(--text-md); /* Default reading text */
--text-heading: var(--text-lg); /* Section titles */
--text-caption: var(--text-sm); /* Helper text */
}

@media (prefers-contrast: high) {
:root {
--text-body-color: #000000;
}
}

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces a clear separation between raw values and semantic usage.
  • Ensures mathematical consistency using a 4px/8px scale.
  • Categorizes tokens to make them easier to maintain in CSS files.

Use this prompt to build a design system foundation from scratch. It works best in ChatGPT, Claude, or Gemini. Paste your answers to the three questions, and the model will output a ready-to-copy CSS file for your project.

Common edits

  • Add your project-specific brand color palette if you need to expand the scope.
  • Adjust the multipliers if your design system uses a 6px or 10px base instead.

Make it repeatable

Keep using this prompt without pasting it in every time.

Keep exploring

More in Design