Style props are a way to alter the style of a component by simply passing props
to it. It helps to save time by providing helpful shorthand ways to style
components.
Reference
The following table shows a list of every style prop and the properties within
each group.
Margin and padding
import { Box } from "@hoverinc/design-system-react-web"// m={2} refers to the value of `theme.space[2]`<Box m={2}>Tomato</Box>// You can also use custom values<Box maxW="960px" mx="auto" />// sets margin `8px` on all viewports and `12px` from the first breakpoint and up<Box m={[2, 3]} />
Prop
CSS Property
Theme Key
m, margin
margin
space
mt, marginTop
margin-top
space
mr, marginRight
margin-right
space
me, marginEnd
margin-inline-end
space
mb, marginBottom
margin-bottom
space
ml, marginLeft
margin-left
space
ms, marginStart
margin-inline-start
space
mx, marginX
margin-inline-start + margin-inline-end
space
my, marginY
margin-top + margin-bottom
space
p, padding
padding
space
pt, paddingTop
padding-top
space
pr, paddingRight
padding-right
space
pe, paddingEnd
padding-inline-end
space
pb, paddingBottom
padding-bottom
space
pl, paddingLeft
padding-left
space
ps, paddingStart
padding-inline-start
space
px, paddingX
padding-inline-start + padding-inline-end
space
py, paddingY
padding-top + padding-bottom
space
For mx and px props, we use margin-inline-start and margin-inline-end
to ensure the generated styles are RTL-friendly
Color and background color
import { Box } from "@hoverinc/design-system-react-web"// picks up a nested color value using dot notation// => `theme.colors.gray[50]`<Box color='gray.50' />// raw CSS color value<Box color='#f00' />// background colors<Box bg='tomato' />// verbose prop<Box backgroundColor='tomato' />
Prop
CSS Property
Theme Key
color
color
colors
bg, background
background
colors
bgColor
background-color
colors
opacity
opacity
none
Gradient
import { Box, Text } from "@hoverinc/design-system-react-web"// adding linear gradient and color transitions<Box w="100%" h="200px" bgGradient="linear(to-t, green.200, pink.500)" />// adding radial gradient and color transitions<Box w="100%" h="200px" bgGradient="radial(gray.300, yellow.400, pink.200)" />// adding the text gradient<Text bgGradient="linear(to-l, #7928CA, #FF0080)" bgClip="text" fontSize="6xl" fontWeight="extrabold"> Welcome to Chakra UI</Text>
Prop
CSS Property
Theme Key
bgGradient
background-image
none
bgClip, backgroundClip
background-clip
none
Typography
import { Text } from "@hoverinc/design-system-react-web"// font-size of `theme.fontSizes.md`<Text fontSize="md" />// font-size `32px`<Text fontSize={32} />// font-size `'2em'`<Text fontSize='2em' />// text-align `left` on all viewports and `center` from the first breakpoint and up<Text textAlign={[ 'left', 'center' ]} />
import { Box } from '@hoverinc/design-system-react-web'// hide the element on all viewports<Box display='none' />// hide the element by default, and show from 'md' up<Box display={{ base: "none", md: "block" }} />// shorthand<Box hideBelow='md' />// hide the element from 'md' up<Box display={{ base: "block", md: "none" }} />// shorthand<Box hideFrom='md' />
Prop
CSS Property
Theme Key
display
display
none
hideFrom
display (at breakpoint)
breakpoints
hideBelow
display (at breakpoint)
breakpoints
Flexbox
import { Box, Flex } from "@hoverinc/design-system-react-web"// verbose<Box display="flex" alignItems="center" justifyContent="space-between"> Box with Flex props</Box>// shorthand using the `Flex` component<Flex align="center" justify="center"> Flex Container</Flex>
Note: Props in * will only work if you use the Flex component.
Prop
CSS Property
Theme Key
gap
gap
space
rowGap
row-gap
space
columnGap
column-gap
space
alignItems, *align
align-items
none
alignContent
align-content
none
justifyItems
justify-items
none
justifyContent, *justify
justify-content
none
flexWrap, *wrap
flex-wrap
none
flexDirection, flexDir, *direction
flex-direction
none
flex
flex
none
flexGrow
flex-grow
none
flexShrink
flex-shrink
none
flexBasis
flex-basis
none
justifySelf
justify-self
none
alignSelf
align-self
none
order
order
none
Grid Layout
import { Box, Grid } from "@hoverinc/design-system-react-web"// verbose<Box display="grid" gridGap={2} gridAutoFlow="row dense"> Grid</Box>// shorthand using the `Grid` component<Grid gap={2} autoFlow="row dense"> Grid</Grid>
Note: Props in * will only work if you use the Grid component.
import { Button } from "@hoverinc/design-system-react-web"// This button will have no right borderRadius<Button borderRightRadius="0">Button 1</Button>// This button will have no left borderRadius*/<Button borderLeftRadius="0">Button 2</Button>// top left and top right radius will be `theme.radii.md` => 4px<Button borderTopRadius="md">Button 2</Button>
Prop
CSS Property
Theme Field
borderRadius
border-radius
radii
borderTopLeftRadius
border-top-left-radius
radii
borderTopStartRadius
border-top-left-radius in LTR, border-top-right-radius in RTL
radii
borderTopRightRadius
border-top-right-radius
radii
borderTopEndRadius
border-top-right-radius in LTR, border-top-left-radius in RTL
radii
borderBottomRightRadius
border-bottom-right-radius
radii
borderBottomEndRadius
border-bottom-right-radius in LTR, border-bottom-left-radius in RTL
radii
borderBottomLeftRadius
border-bottom-left-radius
radii
borderBottomStartRadius
border-bottom-left-radius in LTR, border-bottom-left-radius in RTL
import { Box } from "@hoverinc/design-system-react-web"// verbose<Box position="absolute">Cover</Box>// shorthand<Box pos="absolute">Cover</Box><Box pos="absolute" top="0" left="0"> Absolute with top and left</Box><Box pos="fixed" w="100%" zIndex={2}> Fixed with zIndex</Box>
<Text textShadow='1px 1px #ff0000' m='6'> Text with shadows</Text>
Prop
CSS Property
Theme Field
textShadow
text-shadow
shadows
shadow, boxShadow
box-shadow
shadows
Filter
function Filters() { const basicBoxStyles = { display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', boxSize: '250px', color: 'white', textShadow: '0 0 20px black', fontWeight: 'bold', fontSize: '20px', px: 4, background: 'url(https://picsum.photos/id/1080/200/300) center/cover no-repeat', } return ( <Flex flexWrap='wrap' gap='24px' justifyContent='space-evenly'> {/* adding filter property to the element */} <Box sx={basicBoxStyles} filter='grayscale(80%)'> Box with Filter </Box> {/* adding blur property to the element */} <Box sx={basicBoxStyles} filter='auto' blur='2px'> Box with Blur </Box> {/* adding brightness property to the element */} <Box sx={basicBoxStyles} filter='auto' brightness='40%'> Box with Brightness </Box> </Flex> )}
Note: To apply blur, brightness, contrast, hueRotate, invert,
saturate props on the element, set filter prop value to "auto".
function BackdropFilters() { const outerBoxStyles = { boxSize: '250px', p: '10', background: 'url(https://picsum.photos/id/1068/200/300) center/cover no-repeat', } const innerBoxStyles = { display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', boxSize: 'full', color: 'white', textShadow: '0 0 20px black', fontWeight: 'bold', fontSize: '20px', } return ( <Flex flexWrap='wrap' gap='24px' justifyContent='space-evenly'> {/* adding backdrop-filter property to the element */} <Box sx={outerBoxStyles}> <Box sx={innerBoxStyles} backdropFilter='invert(100%)'> Box with Backdrop Filter </Box> </Box> {/* adding backdrop-blur property to the element */} <Box sx={outerBoxStyles}> <Box sx={innerBoxStyles} backdropFilter='auto' backdropBlur='8px'> Box with Backdrop Blur </Box> </Box> {/* adding backdrop-contrast property to the element */} <Box sx={outerBoxStyles}> <Box sx={innerBoxStyles} backdropFilter='auto' backdropContrast='30%'> Box with Backdrop Contrast </Box> </Box> </Flex> )}
🚨 backdrop-filter is not supported in Firefox. It can be enabled by the
user, but it is suggested to design a component that looks good with and
without this property.
Note: To apply backdropBlur, backdropBrightness, backdropContrast,
backdropHueRotate, backdropInvert, backdropSaturate props on the
element, set backdropFilter prop value to "auto".
Prop
CSS Property
Theme Field
filter
filter
none
blur
filter
blur
brightness
filter
none
contrast
filter
none
hueRotate
filter
none
invert
filter
none
saturate
filter
none
dropShadow
filter
shadows
backdropFilter
backdrop-filter
none
backdropBlur
backdrop-filter
blur
backdropBrightness
backdrop-filter
none
backdropContrast
backdrop-filter
none
backdropHueRotate
backdrop-filter
none
backdropInvert
backdrop-filter
none
backdropSaturate
backdrop-filter
none
Pseudo
import { Button } from "@hoverinc/design-system-react-web"// :hover style<Button colorScheme="teal" _hover={{ background: "white", color: "teal.500", }}> Hover me</Button>// apply :hover over parent element<Box role="group"> <Box _hover={{ fontWeight: 'semibold' }} _groupHover={{ color: 'tomato' }} > </Box></Box>// add ::before pseudo element// Note: the content value needs an extra set of quotes!<Box _before={{ content: '"🙂"', display: 'inline-block', mr: '5px' }}> A pseudo element</Box>