Theme

The theme object is where you define your application's color palette, type scale, font stacks, breakpoints, border-radius values, and more. Theming with Chakra UI is based on the Styled System Theme Specification

Colors#

Add a theme.colors object to provide colors for your project. By default these colors can be referenced by the color, borderColor, and backgroundColor, fill, stroke, styles.

We recommend adding a palette that goes from 50 - 900. Use tools like Coolors or Palx to generate these palettes.

// theme.js
export default {
  colors: {
    transparent: "transparent",
    black: "#000",
    white: "#fff",
    gray: {
      50: "#f7fafc",
      // ...
      900: "#1a202c",
    },
    // ...
  },
};

By default, Chakra UI exposes a default theme object that follows the System UI Theme Specification.

Black & White#

Black
#000
White
#fff

Gray#

gray 50
#F7FAFC
gray 100
#EDF2F7
gray 200
#E2E8F0
gray 300
#CBD5E0
gray 400
#A0AEC0
gray 500
#718096
gray 600
#4A5568
gray 700
#2D3748
gray 800
#1A202C
gray 900
#171923

Cyan#

cyan 50
#EDFDFD
cyan 100
#C4F1F9
cyan 200
#9DECF9
cyan 300
#76E4F7
cyan 400
#0BC5EA
cyan 500
#00B5D8
cyan 600
#00A3C4
cyan 700
#0987A0
cyan 800
#086F83
cyan 900
#065666

Vue#

vue 50
#e1fbf0
vue 100
#c0ecda
vue 200
#9edfc2
vue 300
#79d0aa
vue 400
#55c392
vue 500
#3caa79
vue 600
#2d845e
vue 700
#1d5e42
vue 800
#0c3a26
vue 900
#001508

Green#

green 50
#e2fbed
green 100
#c2ebd4
green 200
#9fddb9
green 300
#7ccf9e
green 400
#58c184
green 500
#3ea76a
green 600
#2e8251
green 700
#1f5d3a
green 800
#0f3921
green 900
#001506

Orange#

orange 50
#ffefdc
orange 100
#ffd4ae
orange 200
#ffba7f
orange 300
#fe9e4d
orange 400
#fd821b
orange 500
#e46902
orange 600
#b25100
orange 700
#7f3900
orange 800
#4e2200
orange 900
#1f0900

Red#

red 50
#ffe5e9
red 100
#f9bcc2
red 200
#ee919a
red 300
#e66673
red 400
#dd3b4b
red 500
#c42231
red 600
#991826
red 700
#6e101a
red 800
#44070e
red 900
#1e0001

Yellow#

yellow 50
#fff9da
yellow 100
#ffecad
yellow 200
#ffdf7d
yellow 300
#ffd24b
yellow 400
#ffc61a
yellow 500
#e6ac00
yellow 600
#b38600
yellow 700
#806000
yellow 800
#4e3900
yellow 900
#1d1300

Indigo#

indigo 50
#f2e5ff
indigo 100
#d2b5ff
indigo 200
#b285fa
indigo 300
#9356f7
indigo 400
#7425f3
indigo 500
#5a0cda
indigo 600
#4608aa
indigo 700
#32057b
indigo 800
#1e024c
indigo 900
#0c001e

Pink#

pink 50
#fff5f7
pink 100
#fed7e2
pink 200
#fbb6ce
pink 300
#f687b3
pink 400
#ed64a6
pink 500
#d53f8c
pink 600
#b83280
pink 700
#97266d
pink 800
#702459
pink 900
#521B41

Blue#

blue 50
#def0ff
blue 100
#afd0ff
blue 200
#7db1ff
blue 300
#4b91ff
blue 400
#1a72ff
blue 500
#0058e6
blue 600
#0045b4
blue 700
#003182
blue 800
#001d51
blue 900
#000a21

Breakpoints#

To configure the default breakpoints used in responsive array values, add a breakpoints array to your theme. These values will be used to generate mobile-first (i.e. min-width) media queries, which can then be used to apply responsive styles.

For example, you can write <c-box :font-size="['14px', '16px']"/> to make the fontSize responsive.

// theme.js
export default {
  breakpoints: ["30em", "48em", "62em", "80em"],
};

Spacing#

The space key allows you to customize the global spacing and sizing scale for your project. By default these spacing values can be referenced by the padding, margin, and top, left, right, bottom styles.

export default {
  space: {
    px: "1px",
    "0": "0",
    "1": "0.25rem",
    "2": "0.5rem",
    "3": "0.75rem",
    "4": "1rem",
    "5": "1.25rem",
    "6": "1.5rem",
    "8": "2rem",
    "10": "2.5rem",
    "12": "3rem",
    "16": "4rem",
    "20": "5rem",
    "24": "6rem",
    "32": "8rem",
    "40": "10rem",
    "48": "12rem",
    "56": "14rem",
    "64": "16rem",
  },
};

By default, Chakra includes a comprehensive numeric spacing scale inspired by Tailwind CSS. The values are proportional, so one spacing unit is equal to 0.25rem, which translates to 4px by default in common browsers.

Mental model: If you need a spacing of 40px, divide it by 4. That'll give you 10. Then use it in your component.

NameSpacePixels
000px
px1px1px
10.25rem4px
20.5rem8px
30.75rem12px
41rem16px
51.25rem20px
61.5rem24px
82rem32px
102.5rem40px
123rem48px
164rem64px
205rem80px
246rem96px
328rem128px
4010rem160px
4812rem192px
5614rem224px
6416rem256px

Sizes#

The sizes key allows you to customize the global sizing of components you build for your project. By default these spacing value can be referenced by the width, height, and maxWidth, minWidth, maxHeight, minHeight styles.

export default {
  sizes: {
    ...theme.space,
    full: "100%",
    "3xs": "14rem",
    "2xs": "16rem",
    xs: "20rem",
    sm: "24rem",
    md: "28rem",
    lg: "32rem",
    xl: "36rem",
    "2xl": "42rem",
    "3xl": "48rem",
    "4xl": "56rem",
    "5xl": "64rem",
    "6xl": "72rem",
  },
};

For a component like this: <c-box w="4" h="3" /> will generate an empty div with width set to 1rem or 16px and height set to 0.75rem or 12px

Z-Index#

Chakra provides some zIndex values out of the box to control the stacking order of components.

export default {
  zIndices: {
    hide: -1,
    auto: "auto",
    base: 0,
    docked: 10,
    dropdown: 1000,
    sticky: 1100,
    banner: 1200,
    overlay: 1300,
    modal: 1400,
    popover: 1500,
    skipLink: 1600,
    toast: 1700,
    tooltip: 1800,
  },
};

Config#

The theme's config is to provide global settings that are used by different parts of the Chakra UI system.

PropertyDescriptionDefault
cssVarPrefixThe prefix to use for the generated CSS custom propertieschakra
initialColorModeThe initial color mode your application should start with.
Can be either light or dark mode
light
useSystemColorModeIf true, the chakra system will update color mode
based on your system preferences
false

You can leverage the extendTheme function to override a specific theme config property.

export default {
  config: {
    cssVarPrefix: "ck",
  },
};

❤️ Contribute to this page

Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!