How to access Lightning tokens in bundle other than defaultTokens.tokens

The Lightning [developer guide][1] is not very helpful on how to use Design tokens:

Tokens created in the defaultTokens bundle are automatically available
in components in your namespace.

Ok, and what if I want to rename it or if another one is already using it? How would I then access them different from:

.THIS p {
    font-family: token(myBodyTextFontFace);
    font-weight: token(myBodyTextFontWeight);
}

Answer

You can create custom tokens, but you cannot reference your custom tokens directly in your lightning component. If you want to create custom token other than Default token then you need to maintain a hierarchical structure of other tokens. Default token will be the parent and all others child and sub-child and so on. To extend Tokens in the parent token use the keyword “extends”.

I would suggest you look into the below link for more info on how to use custom tokens.

Use Tokens in salesforce Lightning

Attribution
Source : Link , Question Author : Robert Sösemann , Answer Author : codeyinthecloud

Leave a Comment