I've styled my website using a theme.js file utilizing emotion and styled-system and want to show the value (e.g #141414) on the front end vs the token name (e.g bgPrimary).
Obviously when I use the token in practice, my website's background is the correct value but I want to showcase the token name and value on the front end as well (for documentation purposes).
An example of how I regularly use it is like so:
background-color: ${props => props.theme.colors.bgPrimary)
But if I wanted to show the value of bgPrimary on the front-end inside a Text component, like so:
<Text value={___} />
how would I have that return the value #141414 without actually hardcoding the HEX value?
Here's how the color object in theme file currently looks:
const colors = {
accent: '#8548FF',
actionPrimary: '#12A55C',
actionPrimaryInteractive: '#0C6E3D',
actionSecondary: '#292929',
actionSecondaryInteractive: '#1F1F1F',
bgPrimary: '#141414',
bgSecondary: '#0A0A0A',
contentPrimary: '#F5F5F5',
contentSecondary: '#8F8F8F',
modes: {
light: {
accent: '#691FFF',
actionPrimary: '#16CA70',
actionPrimaryInteractive: '#109351',
actionSecondary: '#E0E0E0',
actionSecondaryInteractive: '#CCCCCC',
bgPrimary: '#EBEBEB',
bgSecondary: '#F5F5F5',
contentPrimary: '#0A0A0A',
contentSecondary: '#707070',
},
}
}
As you can see, I have two color modes and bgPrimary is different depending on which mode you have set. This is why it's important for the value to be pulled from the theme vs hardcoded.