Skip to content

Instantly share code, notes, and snippets.

@peduarte
Last active May 15, 2021 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peduarte/8cf2e19cf0d72db07b9641bd4fd541e7 to your computer and use it in GitHub Desktop.
Save peduarte/8cf2e19cf0d72db07b9641bd4fd541e7 to your computer and use it in GitHub Desktop.
Radix Colors API Proposal 2

For CSS-in-JS (with tree-shaking):

  • import all colors in light and dark modes
  • import scales in light and dark modes
  • import tokens in light and dark modes
  • make sure the integration with Stitches is as smooth as possible

import all colors in light and dark modes

import { colors, darkColors } from '@radix-ui/colors'

// colors
{
  blue100: '',
  red100: '',
  gray100: '',
}
// darkColors
{
  blue100: '',
  red100: '',
  gray100: '',
}

// With Stitches
createCss({
  theme: {
    colors: colors
  }
})

theme({
  colors: darkColors
})

import scales in light and dark modes

import { blueScale, darkBlueScale } from '@radix-ui/colors'

// blueScale
{
  blue100: '',
  blue200: '',
  blue300: '',
}
// darkBlueScale
{
  blue100: '',
  blue200: '',
  blue300: '',
}
 

// With Stitches
createCss({
  theme: {
    colors: blueScale
  }
})

theme({
  colors: darkBlueScale
})

import tokens in light and dark modes

import { blue200, darkBlue200 } from '@radix-ui/colors'

// blue200
{
  blue200: ''
}
// darkBlue200
{
  blue200: ''
}

// With Stitches
createCss({
  theme: {
    colors: blue200
  }
})

theme({
  colors: darkBlue200
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment