Theme

WorkDS provides a global theme containing values used in both light and dark color modes.

There are two ways of applying these theme values to a UI component:

Theme values can be used as prop values on any UI component. For example, adding margin-right to a button component can be achieved by using the mr prop and passing in a scale value from the spacing scale.

Typically components inherintly have the props needed to style them, but in some cases you may need to add a style that is not available as a prop or set a value that is outside of the specified prop type.

In this case, you can use the style prop to override the component’s default styles. To use theme values with this method, pass the CSS variable name to the CSS property you wish to override. This should be used sparingly, and only when there is no other way to achieve the desired style. For example, to absolute position a box 8px from the top of the page, you can use the style prop to set a top value and pass --space-2 to it.

WorkDS spacing values should be used to create consistent rhythm between elements. These values are based on a 4px base unit. Spacing scale values are typically applied to the margin and padding properties.

ScaleCSS variableValue
1--space-14px
2--space-28px
3--space-312px
4--space-416px
5--space-524px
6--space-632px
7--space-740px
8--space-848px
9--space-964px

Much like Radix Colors, each WorkDS color scale value has a specific use case in mind to ensure that the application of color is accessible and consistent throughout the system.

ScaleUse case
1Background
2Subtle background
3UI element background
4Hovered background
5Active / selected element background
6Subtle borders and separators
7UI element border and focus rings
8Hovered UI element border
9Solid backgrounds
10Hovered solid backgrounds
11Low-contrast text
12High-contrast text

In certain cases, we need to use colors that are different scale values per color mode or are not mapped to a specific color palette. These colors are built into components like Card and Select and should not be used outside of their intended use-case.

CSS variableUse casesLight mode valueDark mode value
--color-backgroundApp backgroundwhitehsl(240 5% 7.5%)
--color-panel-translucentCard backgroundwhitevar(--gray-a1)
--color-panel-solidCode block background, Select item backgroundwhitevar(--gray-2)

Each color palette also includes an alpha scale which is used to create opacity values for the color. These alpha values are created to match the solid color value on the default canvas background. Alpha scale values are identified by the letter a followed by the scale value. For example, --gray-a1 is the alpha value for --gray-1 on the default canvas background.

ScaleCSS variableLight valueDark value
1--gray-1hsl(240 22% 99%)hsl(240, 5%, 9.8%)
2--gray-2hsl(240 20% 98%)hsl(240 6.9% 11.4%)
3--gray-3hsl(239 13.4% 95.4%)hsl(235 6.8% 17.1%)
4--gray-4hsl(238 11.8% 92.9%)hsl(233 6.8% 19.9%)
5--gray-5hsl(237 11.1% 90.5%)hsl(231 6.8% 21.7%)
6--gray-6hsl(236 10.6% 87.9%)hsl(230 6.9% 23.8%)
7--gray-7hsl(234 10.4% 84.4%)hsl(228 7% 27%)
8--gray-8hsl(231 10.2% 75.1%)hsl(225 7.2% 32.5%)
9--gray-9hsl(230 6% 57%)hsl(220 6% 44%)
10--gray-10hsl(227 5.6% 53.1%)hsl(220 5.2% 49.8%)
11--gray-11hsl(220 6% 40%)hsl(220, 7%, 70%)
12--gray-12hsl(210 16% 20%)hsl(220, 10%, 90%)
Alpha scale
a1--gray-a1hsl(240 89.3% 18.3% / 0.012)hsl(240 19.1% 97.9% / 0.026)

Fonts are automatically applied to the correct components, for example the <CodeBlock /> components will get the --code-font-family font family. However, if you need to apply a font family to a custom component, you can use the following font-family CSS variables.

CSS variable nameValue
--default-font-family'Untitled Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'
--code-font-family'IBM Plex Mono', 'Menlo', monospace, 'Apple Color Emoji', 'Segoe UI Emoji'
--em-font-familygeorgia, times, times new roman, serif

Like the spacing scale, font sizing is based on a 4px base unit, however these values are adjust optically for better sizing contrast and baseline alignment.

ScaleCSS variable nameValue
1--font-size-112px
2--font-size-214px
3--font-size-316px
4--font-size-418px
5--font-size-520px
6--font-size-624px
7--font-size-728px
8--font-size-835px
9--font-size-960px
ScaleCSS variable nameValue
1--radius-13px
2--radius-24px
3--radius-36px
4--radius-48px
5--radius-512px
6--radius-616px