radix-ui / colors

A gorgeous, accessible color system.
https://www.radix-ui.com/colors
MIT License
1.38k stars 62 forks source link

Common color keys #36

Open boar-is opened 1 year ago

boar-is commented 1 year ago

Not:

export const gray = {
  gray1: "#fcfcfc",
  gray2: "#f9f9f9",
  gray3: "#f0f0f0",
  // etc.
};

But:

export const gray = {
  1: "#fcfcfc",
  2: "#f9f9f9",
  3: "#f0f0f0",
  // etc.
};

This gives the ability to swap colors dynamically:

function createTheme(palette: Palette) {
  return {
    background: palette[1],
    foreground: palette[12],
    // etc.
  }
}

const blueTheme = createTheme(colors.blue)
const redTheme = createTheme(colors.red)

For example, Tailwind does the same.