For CSS properties that allow multiple values (like border or box-shadow) or within at-rules (like @media queries), Panda provides two syntaxes to reference tokens:
token() function syntax: Useful when you need to provide a fallback value. Syntax: token(path, fallback).- Reference syntax: A more concise syntax for when a fallback is not required. Syntax:
{path}.
Examples
Composite values (e.g., border):
- Using
token(): border: '1px solid token(colors.red.400)' (or with fallback: token(colors.red.400, red)) - Using reference syntax:
border: '1px solid {colors.red.400}'
At-rules (e.g., media queries):
- Using
token(): '@media screen and (min-width: token(sizes.4xl))' - Using reference syntax:
'@media screen and (min-width: {sizes.4xl})'
// token() syntax with fallback
const className = css({ border: '1px solid token(colors.red.400, red)' })
// Reference syntax
const className = css({ border: '1px solid {colors.red.400}' })
// Reference syntax in media queries
const className = css({
'@media screen and (min-width: {sizes.4xl})': {
color: 'green.400'
}
})