Global component

To set global styles use Global component. styles prop accepts:

  • function that subscribes to theme and returns css object or an array of css objects
  • css object or an array of css objects
import { Global } from '@mantine/core';
export function Demo() {
return (
<Global
styles={(theme) => ({
'*, *::before, *::after': {
boxSizing: 'border-box',
},
body: {
...theme.fn.fontStyles(),
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.black,
lineHeight: theme.lineHeight,
},
})}
/>
);
}

Load fonts

To load use array syntax. The following example shows how Mantine docs website loads GreycliffCF font:

import { Global } from '@mantine/core';
import bold from './GreycliffCF-Bold.woff2';
import heavy from './GreycliffCF-Heavy.woff2';
export function Demo() {
return (
<Global
styles={[
{
'@font-face': {
fontFamily: 'Greycliff CF',
src: `url('${bold}') format("woff2")`,
fontWeight: 700,
fontStyle: 'normal',
},
},
{
'@font-face': {
fontFamily: 'Greycliff CF',
src: `url('${heavy}') format("woff2")`,
fontWeight: 900,
fontStyle: 'normal',
},
},
]}
/>
);
}