5

How can I use community:base design tokens in LWC? I created a custom defaultTokens bundle which extends force:base.

<aura:tokens extends="force:base">
    
</aura:tokens>

I want to use the brandLogoImage token in an LWC and have tried the following as described in the documentation. https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.create_components_css_design_tokens

.logoContainer {
  background-image: var(--lwc-brandLogoImage);
}

.logoContainer {
  background-image: var(--c-brandLogoImage);
}
2

1 Answer 1

6

In order to use community tokens you need to extend forceCommunity:base and should work.

In order to debug your component and check if everything work currently you can open Inspector and check your component in the list of styles you should see something like

:root {
   --lwc-brandLogoImage: url('')
}

this would allow you to verify that CSS tokens are added to your page.

For further information please refer to this page Community Token documentation

2
  • Thanks! I mistakenly extended force:base instead of forceCommunity:base. background-image: var(--lwc-brandLogoImage) works now.
    – Jordan
    Mar 1, 2021 at 20:04
  • glad to hear) design tokens sometimes tricky to force working))
    – ytiq
    Mar 2, 2021 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .