Style Props
Style props provide a common, ergonomic API for modifying a component’s styles by passing styles with props.
Style props are deprecated!
As we transition away from Emotion’s runtime costs, we advise to move away from using style props. Please use our styling utilities instead. For more information on this change, view our discussion on the Future of Styling.
You can use 14.1 codemod to automatic migration to cs prop. Migration Docs
System Prop Values
Many style props are design-system-aware and translate SystemPropValues for you automatically. In
the example below, the padding prop translates the value s to 16px and frenchVanilla100 to
#ffffff. These SystemPropValues are also included in our types, so your IDE’s intellisense
should suggest these values as you work. This allows you to use Canvas design tokens fluidly without
disrupting your workflow.
<Box padding="s" backgroundColor="frenchVanilla100">
Hello, style props!
</Box>There are seven types of system prop values: color, depth, font, fontSize, fontWeight,
shape, and space — corresponding to our Canvas design tokens. Each style prop section below
includes a table. The “System” column in that table will tell you which system prop values are
supported.
Background
Background style props allow you to adjust the background styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
display: 'inline-block',
margin: 'xxs',
minHeight: 'xl',
minWidth: '8rem',
padding: 'xs',
};
export default () => {
return (
<div>
<Box backgroundColor="cinnamon300" {...baseStyles}>
Cinnamon 300
</Box>
<Box backgroundColor="sourLemon300" {...baseStyles}>
Sour Lemon 300
</Box>
<Box backgroundColor="blueberry300" {...baseStyles}>
Blueberry 300
</Box>
</div>
);
};
| Prop | CSS Properties | System |
|---|---|---|
| background | color | |
| backgroundAttachment | --- | |
| backgroundColor | color | |
| backgroundImage | --- | |
| backgroundPosition | --- | |
| backgroundRepeat | --- | |
| backgroundSize | --- |
Border
Border style props allow you to adjust the border styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper300',
display: 'inline-block',
margin: 'xxs',
minHeight: 'xl',
minWidth: '8rem',
padding: 'xs',
};
export default () => (
<div>
<Box borderRadius="m" border="solid 4px" borderColor="cinnamon300" {...baseStyles}>
Cinnamon 300
</Box>
<Box borderRadius="m" border="solid 4px" borderColor="sourLemon300" {...baseStyles}>
Sour Lemon 300
</Box>
<Box borderRadius="m" border="solid 4px" borderColor="blueberry300" {...baseStyles}>
Blueberry 300
</Box>
</div>
);
| Prop | CSS Properties | System |
|---|---|---|
| border | --- | |
| borderBottom | --- | |
| borderBottomColor | color | |
| borderBottomLeftRadius | shape | |
| borderBottomRightRadius | shape | |
| borderBottomStyle | --- | |
| borderBottomWidth | --- | |
| borderCollapse | --- | |
| borderColor | color | |
| borderInlineEnd | --- | |
| borderInlineEndColor | color | |
| borderInlineEndStyle | --- | |
| borderInlineEndWidth | --- | |
| borderInlineStart | --- | |
| borderInlineStartColor | color | |
| borderInlineStartStyle | --- | |
| borderInlineStartWidth | --- | |
| borderLeft | --- | |
| borderLeftColor | color | |
| borderLeftStyle | --- | |
| borderLeftWidth | --- | |
| borderRadius | shape | |
| borderRight | --- | |
| borderRightColor | color | |
| borderRightStyle | --- | |
| borderRightWidth | --- | |
| borderSpacing | --- | |
| borderStyle | --- | |
| borderTop | --- | |
| borderTopColor | color | |
| borderTopLeftRadius | shape | |
| borderTopRightRadius | shape | |
| borderTopStyle | --- | |
| borderTopWidth | --- | |
| borderWidth | --- |
Color
Color style props allow you to adjust the color styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
display: 'inline-block',
margin: 'xxs',
minHeight: 'xl',
minWidth: '8rem',
padding: 'xs',
};
export default () => (
<div>
<Box backgroundColor="cinnamon300" color="blackPepper500" {...baseStyles}>
Cinnamon 300
</Box>
<Box backgroundColor="sourLemon300" color="blackPepper500" {...baseStyles}>
Sour Lemon 300
</Box>
<Box backgroundColor="blueberry300" color="blackPepper500" {...baseStyles}>
Blueberry 300
</Box>
</div>
);
| Prop | CSS Properties | System |
|---|---|---|
| backgroundColor | color | |
| color | color | |
| opacity | --- |
Depth
Depth style props allow you to adjust the depth styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
display: 'inline-block',
margin: 'xxs',
minHeight: 'xl',
minWidth: '8rem',
padding: 'xs',
};
export default () => (
<div>
<Box backgroundColor="cinnamon300" depth={1} {...baseStyles}>
Depth 1
</Box>
<Box backgroundColor="sourLemon300" depth={2} {...baseStyles}>
Depth 2
</Box>
<Box backgroundColor="blueberry300" depth={3} {...baseStyles}>
Depth 3
</Box>
</div>
);
| Prop | CSS Properties | System |
|---|---|---|
| boxShadow | --- | |
| depth | depth |
Flex
Flex style props allow you to adjust the flex styles of components.
import {Flex} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
minHeight: 'xl',
minWidth: '2rem',
padding: 'xs',
};
export default () => (
<Flex columnGap="xs">
<Flex flexDirection="column" rowGap="xs" flex={1}>
<Flex.Item backgroundColor="cinnamon300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="sourLemon300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
</Flex>
<Flex flexDirection="column" rowGap="xs" flex={2}>
<Flex.Item backgroundColor="cinnamon300" textAlign="center" {...baseStyles}>
2
</Flex.Item>
<Flex.Item backgroundColor="sourLemon300" textAlign="center" {...baseStyles}>
2
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" textAlign="center" {...baseStyles}>
2
</Flex.Item>
</Flex>
<Flex flexDirection="column" rowGap="xs" flex={1}>
<Flex.Item backgroundColor="cinnamon300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="sourLemon300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" textAlign="center" {...baseStyles}>
1
</Flex.Item>
</Flex>
</Flex>
);
| Prop | CSS Properties | System |
|---|---|---|
| alignContent | --- | |
| alignItems | --- | |
| columnGap | space | |
| display | --- | |
| flexDirection | --- | |
| flexWrap | --- | |
| gap | space | |
| justifyContent | --- | |
| justifyItems | --- | |
| rowGap | space |
Flex Item
Flex item style props allow you to adjust the flex item styles of components.
import {Flex} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
minHeight: 'xl',
minWidth: '2rem',
padding: 'xs',
};
export default () => (
<Flex flexDirection="column" rowGap="xs">
<Flex columnGap="xs">
<Flex.Item backgroundColor="cinnamon300" flex={1} textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="sourLemon300" flex={2} textAlign="center" {...baseStyles}>
2
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" flex={1} textAlign="center" {...baseStyles}>
1
</Flex.Item>
</Flex>
<Flex columnGap="xs">
<Flex.Item backgroundColor="cinnamon300" flex={2} textAlign="center" {...baseStyles}>
2
</Flex.Item>
<Flex.Item backgroundColor="sourLemon300" flex={1} textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" flex={2} textAlign="center" {...baseStyles}>
2
</Flex.Item>
</Flex>
<Flex columnGap="xs">
<Flex.Item backgroundColor="cinnamon300" flex={1} textAlign="center" {...baseStyles}>
1
</Flex.Item>
<Flex.Item backgroundColor="blueberry300" flex={1} textAlign="center" {...baseStyles}>
1
</Flex.Item>
</Flex>
</Flex>
);
| Prop | CSS Properties | System |
|---|---|---|
| alignSelf | --- | |
| flex | --- | |
| flexBasis | --- | |
| flexGrow | --- | |
| flexShrink | --- | |
| justifySelf | --- | |
| order | --- |
Grid
Grid style props allow you to adjust the grid styles of components.
import {Grid} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
padding: 'xs',
};
export default () => (
<Grid
gridGap="xs"
gridTemplateAreas="'head head' 'nav main' 'nav foot'"
gridTemplateColumns="1fr 3fr"
gridTemplateRows="2.5rem minmax(10rem, auto) 2.5rem"
>
<Grid.Item gridArea="head" backgroundColor="cinnamon300" {...baseStyles} />
<Grid.Item gridArea="nav" backgroundColor="sourLemon300" {...baseStyles} />
<Grid.Item gridArea="main" backgroundColor="blueberry300" {...baseStyles} />
<Grid.Item gridArea="foot" backgroundColor="cinnamon300" {...baseStyles} />
</Grid>
);
| Prop | CSS Properties | System |
|---|---|---|
| alignContent | --- | |
| alignItems | --- | |
| display | --- | |
| grid | --- | |
| gridArea | --- | |
| gridAutoColumns | --- | |
| gridAutoFlow | --- | |
| gridAutoRows | --- | |
| gridColumnGap | space | |
| gridGap | space | |
| gridPlaceItems | --- | |
| gridRowGap | space | |
| gridTemplate | --- | |
| gridTemplateAreas | --- | |
| gridTemplateColumns | --- | |
| gridTemplateRows | --- | |
| justifyContent | --- | |
| justifyItems | --- |
Grid Item
Grid item style props allow you to adjust the grid item styles of components.
import {Grid} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
padding: 'xs',
};
export default () => (
<Grid
gridGap="xs"
gridTemplateColumns="1fr 3fr"
gridTemplateRows="2.5rem minmax(10rem, auto) 2.5rem"
>
<Grid.Item gridColumn="1 / 3" gridRow="1" backgroundColor="cinnamon300" {...baseStyles} />
<Grid.Item gridColumn="1" gridRow="2 / 4" backgroundColor="sourLemon300" {...baseStyles} />
<Grid.Item gridColumn="2" gridRow="2" backgroundColor="blueberry300" {...baseStyles} />
<Grid.Item gridColumn="2" gridRow="3" backgroundColor="cinnamon300" {...baseStyles} />
</Grid>
);
| Prop | CSS Properties | System |
|---|---|---|
| alignSelf | --- | |
| gridArea | --- | |
| gridColumn | --- | |
| gridColumnEnd | --- | |
| gridColumnStart | --- | |
| gridRow | --- | |
| gridRowEnd | --- | |
| gridRowStart | --- | |
| justifySelf | --- | |
| placeSelf | --- |
Layout
Layout style props allow you to adjust the layout styles of components.
import {Flex} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
margin: 'xxs',
padding: 'xs',
justifyContent: 'center',
alignItems: 'flex-start',
};
export default () => (
<Flex alignItems="flex-end">
<Flex
backgroundColor="cinnamon300"
display="inline-flex"
height="xl"
width="xxxl"
{...baseStyles}
>
40 x 80
</Flex>
<Flex
backgroundColor="sourLemon300"
display="inline-flex"
height="xxl"
width="xxxl"
{...baseStyles}
>
64 x 80
</Flex>
<Flex
backgroundColor="blueberry300"
display="inline-flex"
height="xxxl"
width="xxxl"
{...baseStyles}
>
80 x 80
</Flex>
</Flex>
);
| Prop | CSS Properties | System |
|---|---|---|
| display | --- | |
| height | space | |
| listStyle | --- | |
| maxHeight | space | |
| maxWidth | space | |
| minHeight | space | |
| minWidth | space | |
| overflow | --- | |
| overflowX | --- | |
| overflowY | --- | |
| verticalAlign | --- | |
| width | space |
Other
Other style props allow you to adjust the other, miscellaneous styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
import {colors} from '@workday/canvas-kit-react/tokens';
const baseStyles = {
color: 'blackPepper500',
display: 'inline-block',
margin: 'xxs',
minHeight: 'xl',
padding: 'xs',
};
export default () => (
<Box>
<Box
backgroundColor="cinnamon300"
cursor="grab"
outline={`2px dashed ${colors.cinnamon300}`}
outlineOffset="2px"
{...baseStyles}
>
Cursor Grab
</Box>
<Box
backgroundColor="sourLemon300"
cursor="text"
outline={`2px dashed ${colors.sourLemon300}`}
outlineOffset="2px"
{...baseStyles}
>
Cursor Text
</Box>
<Box
backgroundColor="blueberry300"
cursor="wait"
outline={`2px dashed ${colors.blueberry300}`}
outlineOffset="2px"
{...baseStyles}
>
Cursor Wait
</Box>
</Box>
);
| Prop | CSS Properties | System |
|---|---|---|
| animation | --- | |
| appearance | --- | |
| boxSizing | --- | |
| content | --- | |
| cursor | --- | |
| fill | --- | |
| float | --- | |
| objectFit | --- | |
| objectPosition | --- | |
| outline | --- | |
| outlineOffset | --- | |
| overflowWrap | --- | |
| pointerEvents | --- | |
| resize | --- | |
| stroke | --- | |
| transform | --- | |
| transition | --- | |
| userSelect | --- | |
| visibility | --- |
Position
Position style props allow you to adjust the position styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
color: 'blackPepper500',
margin: 'xxs',
height: 'xl',
width: '8rem',
padding: 'xs',
};
export default () => {
return (
<div>
<Box
backgroundColor="cinnamon300"
left={0}
position="absolute"
top="calc(50% - 20px)"
zIndex={1}
textAlign="center"
{...baseStyles}
>
Left
</Box>
<Box
backgroundColor="sourLemon300"
left={`calc(50% - 4rem)`}
position="absolute"
top="calc(50% - 20px)"
zIndex={2}
textAlign="center"
{...baseStyles}
>
Center
</Box>
<Box
backgroundColor="blueberry300"
position="absolute"
right={0}
top="calc(50% - 20px)"
zIndex={3}
textAlign="center"
{...baseStyles}
>
Right
</Box>
</div>
);
};
| Prop | CSS Properties | System |
|---|---|---|
| bottom | --- | |
| inset | --- | |
| insetInlineEnd | --- | |
| insetInlineStart | --- | |
| left | --- | |
| position | --- | |
| right | --- | |
| top | --- | |
| zIndex | --- |
Space
Space style props allow you to adjust the space styles of components.
import {Box} from '@workday/canvas-kit-react/layout';
const baseStyles = {
border: 'dotted 2px',
color: 'blackPepper500',
display: 'inline-block',
verticalAlign: 'bottom',
};
export default () => (
<div>
<Box backgroundColor="cinnamon300" margin="xxs" padding="s" textAlign="center" {...baseStyles}>
<Box border="dotted 2px" borderColor="blackPepper500">
Small
</Box>
</Box>
<Box backgroundColor="sourLemon300" margin="xxs" padding="m" textAlign="center" {...baseStyles}>
<Box border="dotted 2px" borderColor="blackPepper500">
Medium
</Box>
</Box>
<Box backgroundColor="blueberry300" margin="xxs" padding="l" textAlign="center" {...baseStyles}>
<Box border="dotted 2px" borderColor="blackPepper500">
Large
</Box>
</Box>
</div>
);
| Prop | CSS Properties | System |
|---|---|---|
| margin | space | |
| marginBottom | space | |
| marginInlineEnd | space | |
| marginInlineStart | space | |
| marginLeft | space | |
| marginRight | space | |
| marginTop | space | |
| marginX | space | |
| marginY | space | |
| padding | space | |
| paddingBottom | space | |
| paddingInlineEnd | space | |
| paddingInlineStart | space | |
| paddingLeft | space | |
| paddingRight | space | |
| paddingTop | space | |
| paddingX | space | |
| paddingY | space |
Text
Text style props allow you to adjust the text styles of components.
The Elements of Typographic Style
"Typography is the craft of endowing human language with a durable visual form."
― Robert Bringhurstimport {Box} from '@workday/canvas-kit-react/layout';
export default () => (
<Box padding="m" border="solid 4px" borderColor="blueberry300" color="blackPepper500">
<Box as="h3" fontSize="large" fontWeight="bold" margin="zero">
The Elements of Typographic Style
</Box>
<Box as="p" fontSize="medium" fontStyle="italic">
"Typography is the craft of endowing human language with a durable visual form."
</Box>
<Box as="span" fontSize="small" fontWeight="bold" color="licorice300">
― Robert Bringhurst
</Box>
</Box>
);
| Prop | CSS Properties | System |
|---|---|---|
| fontFamily | font | |
| fontSize | fontSize | |
| fontStyle | --- | |
| fontWeight | fontWeight | |
| letterSpacing | --- | |
| lineHeight | --- | |
| textAlign | --- | |
| textDecoration | --- | |
| textOverflow | --- | |
| textShadow | --- | |
| textTransform | --- | |
| whiteSpace | --- | |
| wordBreak | --- |
Can't Find What You Need?
Check out our FAQ section which may help you find the information you're looking for. For further information, contact the #ask-canvas-design or #ask-canvas-kitchannels on Slack.