What is the Tokens in lightning component? When it useful?

Tokens are a part of lightning component bundle same as component,event bundle.  Tokens are holds necessary values of our visual design into named tokens. So we can Define the token values once and reuse them multiple times in our Lightning components CSS style.

Make sure your first tokens bundle should be named defaultTokens.

We can call multiple token throughout default tokens as well.

For Example:-

.THIS .customToken{ padding:token(boxPaddToken);}
.THIS .customToken thead{ background-color:token(tokenBackground); color:token(colorToken);}
.THIS .customToken thead th{padding:token(boxPaddToken); border:token(boxBorderToken) #ccc solid;}
.THIS .customToken tbody td{padding:token(boxPaddToken); border:token(boxBorderToken) #ccc solid;}

defaultTokens.tokens

.THIS .customToken{ padding:token(boxPaddToken);}
aura:tokens extends="c:myCustomToken"
aura:token name="changeColor" value="green"
aura:token name="TextColor" value="yellow"
aura:tokens

myCustomToken.tokens


aura:token name="colorToken" value="red" aura:token
aura:token name="boxPaddToken" value="10px" aura:token
aura:token name="boxMarginToken" value="20px" aura:token
aura:token name="boxBorderToken" value="1px" aura:token
aura:token name="tokenBackground" value="#ddd" aura:token



To know more live demo source code in Salesforce lightning, Trigger, Visualforce & LWC, Use this link..



What is the Tokens in lightning component? When it useful? What is the Tokens in lightning component? When it useful? Reviewed by Admin on 12:06 AM Rating: 5

6 comments:

header banner -- www.w3web.net



Powered by Blogger.