Skip to content

Help with dynamic switching of Carbon Themes #8272

Answered by jnm2377
nikhilkomakula asked this question in Help
Discussion options

You must be logged in to vote

Hi 👋🏽 when you say dynamic switching, do you mean how we have a dropdown for our component demo that switches the specific zone theme? If so, we utilize css custom properties. We have a feature flag that you can turn on that will allow you to use custom properties. Then you can set different themes within certain zones.

In your index.scss you'd have this:

$feature-flags: (
  enable-css-custom-properties: true,
);

@import "carbon-components/scss/globals/scss/styles.scss";

Then you can create themed "zones" like this:

//form page styles
.g90 {
  @include carbon--theme(
    $theme: $carbon--theme--g100,
    $emit-custom-properties: true
  );
}

And rather than using our regular tokens, use o…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nikhilkomakula
Comment options

@tw15egan
Comment options

@nikhilkomakula
Comment options

Answer selected by jnm2377
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