Click in order · JavaScript and React course · Module 14: Advanced Styling

Token to CSS Variable

Arrange the steps for converting a JavaScript token to a CSS Variable in React:

Items to click

  • Use in CSS: background: var(--color-primary)
  • Define token: tokens.colors.primary = '#7c4dff'
  • Convert to CSS var: vars['--color-primary'] = tokens.colors.primary
  • Pass to style: <div style={vars}>

You can check the correct answer by solving this task in the CodeWorlds game.