Extending Mantine Default Size & Spacing Values #4966
Replies: 3 comments 4 replies
-
Same here. |
Beta Was this translation helpful? Give feedback.
-
In case you're still facing this issue, here's what worked for me. I extended the Mantine theme to include the 'xxl' spacing token without overriding the core type definition. First, in your global.d.ts: import { MantineTheme } from "@mantine/core";
declare module "@mantine/core" {
export interface MantineThemeOverride extends MantineTheme {
spacing: Record<"xs" | "sm" | "md" | "lg" | "xl" | "xxl", string>;
}
} Then, in your theme overrides: spacing: {
xxl: "4rem",
},
... |
Beta Was this translation helpful? Give feedback.
-
I'd love a way to improve DX and extend e.g. It does work in runtime when you add it in Would be awesome to leverage module augmentation similarly to how we can do with |
Beta Was this translation helpful? Give feedback.
-
I have been struggling extending mantine theme to support additional size and spacing tokens such as
2xl
.I realize that we can add additional values by adding them via
createTheme
and passing this to theMantineProvider
for instance:This does work however this does not extend the MantineSpacing type definition and leads to bad DX as intellisense and suggestions will only pick up the default MantineSpacing values
'xs' | 'sm' | 'md' | 'lg' | 'xl'
I could simply override the MantineTheme type definition with my own declaration but I would rather not do so for numerous reasons...
I feel like there should be some way to add additional tokens like I described above. Or am I overlooking some already existing behavior?
Beta Was this translation helpful? Give feedback.
All reactions