Tokens
Tokens are a valuable asset to your design system, as this is the source of truth for most of your CSS property values. By creating and managing tokens using powerful vanilla CSS features like the CSS custom properties feature, you'll be able to create a very reliable source of truth for your design system. Sentro makes this process very easy to do and to maintain.
Basic Usage
Configuring tokens
Configure your tokens using the sentro.token-config()
mixin.
It can be a map with a default value and variants, or a separate variable argument. For maps, the default
key is the set non-variant key for the parent key (please see the examples below).
The token-config()
mixin also supports map-based token sets using the $map
parameter.
Two-way token configuration
It also supports both at the same time.
Nesting tokens
You can also nest tokens. Though we do not recommend nesting too deep as it can be hard to manage. We recommend using up until 2 levels of nesting. This leaves you with a good balance between manageability and flexibility.
Using tokens
Using these tokens in your CSS property values using the sentro.token-get()
function.
If the token you created has the default
as the key of its variant, you won't have to point it to add default
to
your token-get()
key as sentro automatically maps it for you.
CSS Output
Using tokens with !important
You can also use the sentro.token-get()
function with the !important
flag attached to the value. By default, the
!important
flag is set to false
.
CSS Output
Using tokens with a custom separator
When you want to use custom separators for your tokens, the global separator can be changed using the $separator
parameter. Please refer to this guide for more information.