Mantine CSS variables
MantineProvider exposes all Mantine CSS variables based on the given theme. You can use these variables in CSS files, style prop or any other styles. Note that not all values are documented on this page, you can find full list of variables on this page.
Typography CSS variables
The following CSS variables are used to control all typography styles (font-family
, font-size
, line-height
)
in all Mantine components:
Variable | Default value |
---|---|
--mantine-font-family | -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji |
--mantine-font-family-monospace | ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace |
--mantine-font-family-headings | -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji |
--mantine-font-size-xs | 0.75rem |
--mantine-font-size-sm | 0.875rem |
--mantine-font-size-md | 1rem |
--mantine-font-size-lg | 1.125rem |
--mantine-font-size-xl | 1.25rem |
--mantine-line-height-xs | 1.4 |
--mantine-line-height-sm | 1.45 |
--mantine-line-height-md | 1.55 |
--mantine-line-height-lg | 1.6 |
--mantine-line-height-xl | 1.65 |
Usage:
Spacing
Spacing CSS variables are used to control margins and paddings in most of Mantine components.
They are also used in p
and m
style props:
Variable | Default value |
---|---|
--mantine-spacing-xs | 0.625rem |
--mantine-spacing-sm | 0.75rem |
--mantine-spacing-md | 1rem |
--mantine-spacing-lg | 1.25rem |
--mantine-spacing-xl | 2rem |
Usage:
Shadows
Shadows CSS variables are used to control shadows in all Mantine components that support shadow
prop:
Variable | Default value |
---|---|
--mantine-shadow-xs | |
--mantine-shadow-sm | |
--mantine-shadow-md | |
--mantine-shadow-lg | |
--mantine-shadow-xl |
Usage:
Radius
Radius CSS variables are used to control border-radius in all Mantine components that support radius
prop:
Variable | Default value |
---|---|
--mantine-radius-default | 0.25rem |
--mantine-radius-xs | 0.125rem |
--mantine-radius-sm | 0.25rem |
--mantine-radius-md | 0.5rem |
--mantine-radius-lg | 1rem |
--mantine-radius-xl | 2rem |
Usage:
Colors
All theme.colors
values are exposed as CSS variables in --mantine-color-{x}-{y}
format,
where x
is the color name and y
is the color shade. For example, --mantine-color-red-6
is theme.colors.red[6]
.
You can find the full default colors list in the colors guide.
Usage:
Variant specific colors
Variant specific variables for each color are exposed in the following format
(x
is the color name):
--mantine-color-{x}-filled
– filled variant background-color--mantine-color-{x}-filled-hover
– filled variant background-color on hover--mantine-color-{x}-light
– light variant background-color--mantine-color-{x}-light-hover
– light variant background-color on hover--mantine-color-{x}-light-color
– light variant text color--mantine-color-{x}-outline
– outline variant border-color and text color--mantine-color-{x}-outline-hover
– outline variant background-color on hover
Usage:
Other colors variables
--mantine-color-white
– value oftheme.white
--mantine-color-black
– value oftheme.black
--mantine-color-text
– text color set onbody
element--mantine-color-body
–body
element background-color--mantine-color-error
– error color, used in Input and other similar components--mantine-color-placeholder
– placeholder color, used in Input and other similar components to set text color of placeholder--mantine-color-anchor
– anchor color, used in Anchor component--mantine-color-default
– default variant background-color--mantine-color-default-hover
– default variant background-color on hover--mantine-color-default-color
– default variant text color--mantine-color-default-border
– default variant border-color
Usage:
CSS variables resolver
cssVariablesResolver
prop on MantineProvider allows you to
modify values of Mantine CSS variables or even add your own variables.
cssVariablesResolver
is a function that accepts theme as a single
argument and returns an object with CSS variables divided into three groups:
variables
– variables that do not depend on color schemelight
– variables for light color scheme onlydark
– variables for dark color scheme only
Example of adding new CSS variables based on theme.other
:
Then you will be able to use --mantine-hero-height
and --mantine-color-deep-orange
variables
in any part of your application: