Skip to content

Can you create your own tokens that works with themes? #12911

Closed Answered by tay1orjones
jeppetn asked this question in Help
Discussion options

You must be logged in to vote

Yes to add custom tokens to multiple existing themes, you'll need to merge your own custom tokens into the existing theme maps before invoking the theme() mixin.

We don't yet have an example of this, but it could look like the following:

@use '@carbon/react/scss/themes';
@use '@carbon/react/scss/theme';
@use '@carbon/react';

// Define custom token maps for each theme
$g10-custom-tokens: (
  custom-token-1: #000,
  custom-token-2: #000
);

$g100-custom-tokens: (
  custom-token-1: #fff,
  custom-token-2: #fff
);

// Merge the custom tokens into the existing theme maps
$g10: utilities.merge(
  themes.$g10
  $g10-custom-tokens
);

$g100: utilities.merge(
  themes.$g100
  $g100-custom-tokens

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jeppetn
Comment options

Answer selected by jeppetn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants