Style Props

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

<template>  <!-- m="2" refers to the value of theme.space.[2] -->  <CBox m="2">Tomato</CBox>  
  <!-- You can also make use of custom values -->  <CBox max-w="960px" mx="auto">Custom</CBox>  
  <!-- sets margin `8px` on all viewports and `12px` from the first breakpoint and up -->  <CBox :m="['2', '3']" /></template>
PropCSS PropertyTheme Key
m, marginmarginspace
mt, margin-topmargin-topspace
mr, margin-rightmargin-rightspace
me, margin-endmargin-inline-endspace
mb, margin-bottommargin-bottomspace
ml, margin-leftmargin-leftspace
ms, margin-startmargin-inline-startspace
mx, margin-xmargin-inline-start + margin-inline-endspace
my, margin-ymargin-top + margin-bottomspace
p, paddingpaddingspace
pt, padding-toppadding-topspace
pr, padding-rightpadding-rightspace
pe, padding-endpadding-inline-endspace
pb, padding-bottompadding-bottomspace
pl, padding-leftpadding-leftspace
ps, padding-startpadding-inline-startspace
px, padding-xpadding-inline-start + padding-inline-endspace
py, padding-ypadding-top + padding-bottomspace

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

<template>  <!-- picks up a nested color value using dot notation -->  <CBox color="gray.50" />  
  <!-- You can also use raw CSS color values -->  <CBox color="#f00" />  
  <!-- Sets background color to pink -->  <CBox bg="pink" /></template>
PropCSS PropertyTheme Key
colorcolorcolors
bg, backgroundbackgroundcolors
bg-colorbackground-colorcolors
opacityopacitynone

Gradient

<template>  <!-- adding linear gradient and color transitions -->  <CBox w="100%" h="200px" bg-gradient="linear(to-t, green.200, pink.500)" />  
  <!-- adding radial gradient and color transitions -->  <CBox w="100%" h="200px" bg-gradient="radial(gray.300, yellow.400, pink.200)" />  
  <!-- adding the text gradient -->  <CText    bg-gradient="linear(to-l, #7928CA, #FF0080)"    bg-clip="text"    font-size="6xl"    font-weight="extrabold"  >    Welcome to Chakra UI Vue
  </CText></template>
PropCSS PropertyTheme Key
bg-gradientbackground-imagenone
bg-clip, background-clipbackground-clipnone

Typography

<template>  <!-- font-size of `theme.fontSizes.md` -->  <CText font-size="md" />  
  <!-- font-size `32px` -->  <CText font-size="32" />  
  <!-- font-size `'2em'` -->  <CText font-size="2em" />  
  <!-- text-align `left` on all viewports and `center` from the first breakpoint and up -->  <CText :text-align="[ 'left', 'center' ]" /></template>
PropCSS PropertyTheme Key
font-familyfont-familyfonts
font-sizefont-sizefontSizes
font-weightfont-weightfontWeights
line-heightline-heightlineHeights
letter-spacingletter-spacingletterSpacings
text-aligntext-alignnone
font-stylefont-stylenone
text-transformtext-transformnone
text-decorationtext-decorationnone

Layout, width and height

<template>  <!-- verbose -->  <CBox width="100%" height="32px" />  
  <!-- shorthand -->  <CBox w="100%" h="32px" />  
  <!-- width `256px` -->  <CBox w="256" />  
  <!-- width `'40px'` -->  <CBox w="40px" /></template>
PropCSS PropertyTheme Key
w, widthwidthsizes
h, heightheightsizes
min-w, min-widthmin-widthsizes
max-x, max-widthmax-widthsizes
minH, min-heightmin-heightsizes
maxH, max-heightmax-heightsizes
box-sizewidth, heightsizes
vertical-alignvertical-alignnone
overflowoverflownone
overflow-xoverflow-xnone
overflow-yoverflow-ynone

Display

<template>  <!-- hide the element on all viewports -->  <CBox display='none' />  
  <!-- hide the element by default, and show from 'md' up -->  <CBox :display="{ base: 'none', md: 'block' }" />  
  <!-- shorthand -->  <CBox hide-below='md' />  
  <!-- hide the element from 'md' up -->  <CBox :display="{ base: 'block', md: 'none' }" />  
  <!-- shorthand -->  <CBox hide-from='md' /></template>
PropCSS PropertyTheme Key
displaydisplaynone
hide-fromdisplay (at breakpoint)breakpoints
hide-belowdisplay (at breakpoint)breakpoints

Flexbox

<template>  <!-- verbose -->  <CBox display="flex" align-items="center" justify-content="space-between">    Box with Flex props
  </CBox>  
  <!-- shorthand using the `Flex` component -->  <CFlex align="center" justify="center">    Flex Container
  </CFlex></template>

Note: Props in * will only work if you use the Flex component.

PropCSS PropertyTheme Key
gapgapspace
row-gaprow-gapspace
column-gapcolumn-gapspace
align-items, *alignalign-itemsnone
align-contentalign-contentnone
justify-itemsjustify-itemsnone
justify-content, *justifyjustify-contentnone
flex-wrap, *wrapflex-wrapnone
flex-direction, flex-dir, *directionflex-directionnone
flexflexnone
flex-growflex-grownone
flex-shrinkflex-shrinknone
flex-basisflex-basisnone
justify-selfjustify-selfnone
align-selfalign-selfnone
orderordernone

Grid Layout

<template>  <!-- verbose -->  <CBox display="grid" grid-gap="2" grid-auto-flow="row dense">    Grid
  </CBox>  
  <!-- shorthand using the `Grid` component -->  <CGrid gap="2" auto-flow="row dense">    Grid
  </CGrid></template>

Note: Props in * will only work if you use the Grid component.

PropCSS PropertyTheme Key
grid-gap, *gapgrid-gapspace
grid-row-cap, *row-gapgrid-row-gapspace
grid-column-gap, *column-gapgrid-column-gapspace
grid-column, *columngrid-columnnone
grid-row, *rowgrid-rownone
grid-area, *areagrid-areanone
grid-auto-flow, *auto-flowgrid-auto-flownone
grid-auto-rows, *auto-rowsgrid-auto-rowsnone
grid-auto-columns, *auto-columnsgrid-auto-columnsnone
grid-template-rows, *template-rowsgrid-template-rowsnone
grid-template-columns, *template-columnsgrid-template-columnsnone
grid-template-areas, *template-areasgrid-template-areasnone

Background

<template>  <!-- verbose -->  <CBox    background-image="url('/images/kyuubi.png')"    background-position="center"    background-repeat="no-repeat"  >  
  <!-- shorthand -->  <CBox bg-image="url('/images/gaara.png')" bg-pos="center" bg-repeat="no-repeat" ></template>
PropCSS PropertyTheme Key
bg, backgroundbackgroundnone
bg-image, background-imagebackground-imagenone
bg-size, background-sizebackground-sizenone
bg-position,background-positionbackground-positionnone
bg-repeat,background-repeatbackground-repeatnone
bg-attachment,background-attachmentbackground-attachmentnone

Borders

<template>  <CBox border="1px" border-radius="md" border-color="gray.200">    Card
  </CBox></template>
PropCSS PropertyTheme Field
borderborderborders
border-widthborder-widthborderWidths
border-styleborder-styleborderStyles
border-colorborder-colorcolors
border-topborder-topborders
border-top-widthborder-top-widthborderWidths
border-top-styleborder-top-styleborderStyles
border-top-colorborder-top-colorcolors
border-rightborder-rightborders
border-endborder-inline-endborders
border-right-widthborder-right-widthborderWidths
border-end-widthborder-inline-end-widthborderWidths
border-right-styleborder-right-styleborderStyles
border-end-styleborder-inline-end-styleborderStyles
border-right-colorborder-right-colorcolors
border-end-colorborder-inline-end-colorcolors
border-bottomborder-bottomborders
border-bottom-widthborder-bottom-widthborderWidths
border-bottom-styleborder-bottom-styleborderStyles
border-bottom-colorborder-bottom-colorcolors
border-leftborder-leftborders
border-startborder-inline-startborders
border-left-widthborder-left-widthborderWidths
border-start-widthborder-inline-start-widthborderWidths
border-left-styleborder-left-styleborderStyles
border-start-styleborder-inline-start-styleborderStyles
border-left-colorborder-left-colorcolors
border-start-colorborder-inline-start-colorcolors
border-xborder-left , border-rightborders
border-yborder-top , border-bottomborders

Border Radius

<template>  <!-- This button will have no right borderRadius -->  <CButton rounded-right="0">Button 1</CButton>  <!-- This button will have no left borderRadius*/ -->  <CButton rounded-left="0">Button 2</CButton>  <!-- top left and top right radius will be `theme.radii.md` => 4px -->  <CButton rounded-top="md">Button 2</CButton></template>
PropCSS PropertyTheme Field
border-radiusborder-radiusradii
border-top-left-radiusborder-top-left-radiusradii
border-top-start-radiusborder-top-left-radius in LTR,
border-top-right-radius in RTL
radii
border-top-right-radiusborder-top-right-radiusradii
border-top-end-radiusborder-top-right-radius in LTR,
border-top-left-radius in RTL
radii
border-bottom-right-radiusborder-bottom-right-radiusradii
border-bottom-end-radiusborder-bottom-right-radius in LTR,
border-bottom-left-radius in RTL
radii
border-bottom-left-radiusborder-bottom-left-radiusradii
border-bottom-start-radiusborder-bottom-left-radius in LTR,
border-bottom-left-radius in RTL
radii
border-top-radiusborder-top-left-radius + border-top-right-radiusradii
border-right-radiusborder-top-right-radius + border-bottom-right-radiusradii
border-end-radiusborder-top-right-radius + border-bottom-right-radiusradii
border-bottom-radiusborder-bottom-left-radius + border-bottom-right-radiusradii
border-left-radiusborder-top-left-radius + border-bottom-left-radiusradii
border-start-radiusborder-top-left-radius + border-bottom-left-radiusradii

Position

<template>  <!-- verbose -->  <CBox position="absolute">Cover</CBox>  
  <!-- shorthand -->  <CBox pos="absolute">Cover</CBox>  
  <CBox pos="absolute" top="0" left="0">    Absolute with top and left
  </CBox>  
  <CBox pos="fixed" w="100%" z-index="2">    Fixed with zIndex
  </CBox></template>
PropCSS PropertyTheme Field
pos,positionpositionnone
z-indexz-indexzIndices
toptopspace
rightrightspace
bottombottomspace
leftleftspace

Shadow

<template>  <!-- verbose -->  <!-- text-shadow will be `theme.shadows.sm` -->  <!-- box-shadow will be `theme.shadows.md` -->  <CBox text-shadow="sm" box-shadow="md" />  
  <!-- raw CSS values -->  <CText text-shadow="2px 2px #ff0000" box-shadow="5px 10px #888888">    Text with shadows
  </CText></template>
PropCSS PropertyTheme Field
text-shadowtext-shadowshadows
shadow, box-shadowbox-shadowshadows

Filter

<script setup>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",};</script>  
<template>  <CFlex flex-wrap="wrap" gap="24px" justify-content="space-evenly">    <!-- adding filter property to the element -->    <CBox :sx="basicBoxStyles" filter="grayscale(80%)"> Box with Filter </CBox>    
    <!-- adding blur property to the element -->    <CBox :sx="basicBoxStyles" filter="auto" blur="2px"> Box with Blur </CBox>    
    <!-- adding brightness property to the element -->    <CBox :sx="basicBoxStyles" filter="auto" brightness="40%">      Box with Brightness    </CBox>  </CFlex></template>

Note: To apply blur, brightness, contrast, hueRotate, invert, saturate props on the element, set filter prop value to "auto".

<script setup>  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",};</script>  
<template>  <CFlex flex-wrap="wrap" gap="24px" justify-content="space-evenly">    <!-- adding backdrop-filter property to the element -->    <CBox :sx="outerBoxStyles">      <CBox :sx="innerBoxStyles" backdrop-filter="invert(100%)">        Box with Backdrop Filter      </CBox>    </CBox>    
    <!-- adding backdrop-blur property to the element -->    <CBox :sx="outerBoxStyles">      <CBox :sx="innerBoxStyles" backdrop-filter="auto" backdrop-blur="8px">        Box with Backdrop Blur      </CBox>    </CBox>    
    <!-- adding backdrop-contrast property to the element -->    <CBox :sx="outerBoxStyles">      <CBox :sx="innerBoxStyles" backdrop-filter="auto" backdrop-contrast="30%">        Box with Backdrop Contrast      </CBox>    </CBox>  </CFlex></template>

🚨 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".

PropCSS PropertyTheme Field
filterfilternone
blurfilterblur
brightnessfilternone
contrastfilternone
hue-rotatefilternone
invertfilternone
saturatefilternone
drop-shadowfiltershadows
backdrop-filterbackdrop-filternone
backdrop-blurbackdrop-filterblur
backdrop-brightnessbackdrop-filternone
backdrop-contrastbackdrop-filternone
backdrop-hue-rotatebackdrop-filternone
backdrop-invertbackdrop-filternone
backdrop-saturatebackdrop-filternone

Pseudo

<template>  <!-- :hover style -->  <CButton    color-scheme="teal"    :_hover="{
      background: 'white',
      color: 'teal.500',
    }"  >    Hover me
  </CButton>  
  <!-- apply :hover over parent element -->  <CBox role="group">    <CBox      :_hover="{ fontWeight: 'semibold' }"      :_group-hover="{ color: 'tomato' }"    >      Hello
    </CBox>  </CBox>  
  <!-- add ::before pseudo element -->  <!-- Note: the content value needs an extra set of quotes! -->  <CBox    :_before="{
      content: `'🙂'`,
      display: 'inline-block',
      mr: '5px',
    }"  >    A pseudo element
  </CBox></template>
PropCSS PropertyTheme Field
_hover&:hover
&[data-hover]
none
_active&:active
&[data-active]
none
_focus&:focus
&[data-focus]
none
_highlighted&[data-highlighted]none
_focus-within&:focus-withinnone
_focus-visible&:focus-visiblenone
_disabled&[disabled]
&[aria-disabled=true]
&[data-disabled]
none
_readOnly&[aria-readonly=true]
&[readonly]
&[data-readonly]
none
_before&::beforenone
_after&::afternone
_empty&:emptynone
_expanded&[aria-expanded=true]
&[data-expanded]
none
_checked&[aria-checked=true]
&[data-checked]
none
_grabbed&[aria-grabbed=true]
&[data-grabbed]
none
_pressed&[aria-pressed=true]
&[data-pressed]
none
_invalid&[aria-invalid=true]
&[data-invalid]
none
_valid&[data-valid]
&[data-state=valid]
none
_loading&[data-loading]
&[aria-busy=true]
none
_selected&[aria-selected=true]
&[data-selected]
none
_hidden&[hidden]
&[data-hidden]
none
_autofill&:-webkit-autofillnone
_even&:nth-of-type(even)none
_odd&:nth-of-type(odd)none
_first&:first-of-typenone
_last&:last-of-typenone
_notFirst&:not(:first-of-type)none
_notLast&:not(:last-of-type)none
_visited&:visitednone
_active-link&[aria-current=page]none
_active-step&[aria-current=step]none
_indeterminate&:indeterminate
&[aria-checked=mixed]
&[data-indeterminate]
none
_group-hover[role=group]:hover &
[role=group][data-hover] &
[data-group]:hover &
[data-group][data-hover] &
.group:hover &
.group[data-hover] &
none
_peer-hover[data-peer]:hover ~ &
[data-peer][data-hover] ~ &
.peer:hover ~ &
.peer[data-hover] ~ &
none
_group-focus[role=group]:focus &
[role=group][data-focus] &
[data-group]:focus &
[data-group][data-focus] &
.group:focus &
.group[data-focus] &
none
_peer-focus[data-peer]:focus ~ &
[data-peer][data-focus] ~ &
.peer:focus ~ &
.peer[data-focus] ~ &
none
_group-focus-visible[role=group]:focus-visible &
[data-group]:focus-visible &
.group:focus-visible &
none
_peer-focus-visible[data-peer]:focus-visible ~ &
.peer:focus-visible ~ &
none
_group-active[role=group]:active &
[role=group][data-active] &
[data-group]:active &
[data-group][data-active] &
.group:active &
.group[data-active] &
none
_peer-active[data-peer]:active ~ &
[data-peer][data-active] ~ &
.peer:active ~ &
.peer[data-active] ~ &
none
_group-disabled[role=group]:disabled &
[role=group][data-disabled] &
[data-group]:disabled &
[data-group][data-disabled] &
.group:disabled &
.group[data-disabled] &
none
_peer-disabled[data-peer]:disabled ~ &
[data-peer][data-disabled] ~ &
.peer:disabled ~ &
.peer[data-disabled] ~ &
none
_group-invalid[role=group]:invalid &
[role=group][data-invalid] &
[data-group]:invalid &
[data-group][data-invalid] &
.group:invalid &
.group[data-invalid] &
none
_peer-invalid[data-peer]:invalid ~ &
[data-peer][data-invalid] ~ &
.peer:invalid ~ &
.peer[data-invalid] ~ &
none
_group-checked[role=group]:checked &
[role=group][data-checked] &
[data-group]:checked &
[data-group][data-checked] &
.group:checked &
.group[data-checked] &
none
_peer-checked[data-peer]:checked ~ &
[data-peer][data-checked] ~ &
.peer:checked ~ &
.peer[data-checked] ~ &
none
_group-focus-within[role=group]:focus-within &
[data-group]:focus-within &
.group:focus-within &
none
_peer-focus-within[data-peer]:focus-within ~ &
.peer:focus-within ~ &
none
_peer-placeholder-shown[data-peer]:placeholder-shown ~ &
.peer:placeholder-shown ~ &
none
_placeholder&::placeholdernone
_placeholder-shown&:placeholder-shownnone
_full-screen&:fullscreennone
_selection&::selectionnone
_rtl[dir=rtl] &
&[dir=rtl]
none
_ltr[dir=ltr] &
&[dir=ltr]
none
_media-dark@media (prefers-color-scheme: dark)none
_media-reduce-motion@media (prefers-reduced-motion: reduce)none
_dark.chakra-ui-dark &
[data-theme=dark] &
&[data-theme=dark]
none
_light.chakra-ui-light &
[data-theme=light] &
&[data-theme=light]
none

Other Props

Asides all the common style props listed above, all component will accept the following props:

PropCSS PropertyTheme Field
animationanimationnone
appearanceappearancenone
contentcontentnone
transformtransformnone
transform-origintransform-originnone
visibilityvisibilitynone
white-spacewhite-spacenone
user-selectuser-selectnone
pointer-eventspointer-eventsnone
word-breakword-breaknone
overflow-wrapoverflow-wrapnone
text-overflowtext-overflownone
box-sizingbox-sizingnone
cursorcursornone
resizeresizenone
transitiontransitionnone
object-fitobject-fitnone
object-positionobject-positionnone
floatfloatnone
fillfillcolors
strokestrokecolors
outlineoutlinenone

The as prop

The as prop is a feature in all of our components that allows you to pass an HTML tag or component to be rendered.

For example, say you are using a Button component, and you need to make it a link instead. You can compose a and Button like this:

<template>  <CButton as="router-link" to="/about">About Page Button</CButton></template>

This allows you to use all of the Button props and all of the a props without having to wrap the Button in an a component.

Edit this page on GitHub