Skip to content

How to use style variables in CSS/SCSS files #1535

Answered by TheSisb
HartiganHM asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @HartiganHM,

There are several ways to consume tokens from Paste, ordered from our most preferred to least:


Using the Box primitive

<Box backgroundColor="colorBackground"> ...

docs for Box primitive

Using our CSS-in-JS

import {styled, css} from '@twilio-paste/core/styling-library';

const custom = styled.div(
  css({
    backgroundColor: 'colorBackgroundPrimary',
    padding: 'spacing20',
  })
);

docs for css-in-js

Grabbing tokens from theme context

import {Theme} from '@twilio-paste/core/theme';

<Theme.Consumer>
  {({theme}) => {
    return <p>What is the default text color {theme.textColors.colorText}</p>;
  }}
</Theme.Consumer>

or

import {useTheme} from '@twilio-paste/core/theme';

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TheSisb
Comment options

@HartiganHM
Comment options

Answer selected by TheSisb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants