MantineProvider
MantineProvider component allows you to change theme globally. It is not required if you decide to use default theme:
use-mantine-theme hook
Hook returns theme from MantineProvider context or default theme if you did not wrap application with MantineProvider.
Theme object
Mantine theme is an object where your application's colors, fonts, spacing, border-radius and other design elements are defined.
Theme shape:
Pass theme object to MantineProvider to change global styles:
Nested MantineProviders
If some parts of your application require different theme styles you can wrap them in another MantineProvider. Nested MantineProvider components do not inherit theme properties from parents and merge theme prop with default theme.
Styles on MantineProvider
You can add styles to components that support Styles API with MantineProvider. All components that are rendered inside MantineProvider will inherit those styles:
Normalize.css and global styles
MantineProvider includes normalize.css and some extra global styles:
- background color to
theme.colors.dark[7]in dark color scheme andtheme.whitein light - color to
theme.colors.dark[0]in dark color scheme andtheme.blackin light - font-family and font-smoothing based on theme
- font-size to
theme.fontSize.md
To enable these global styles set withNormalizeCSS and withGlobalStyles props:
Configure emotion
You can configure emotion cache options in MantineProvider.
These options are usually used to configure styles insertion point. By default Mantine components styles and
styles created with createStyles function are prepended to head. To change that behavior set prepend option to false:
Emotion cache also allows you to use Stylis plugins. For example, you can use stylis-plugin-rtl to add rtl support: