Custom components
This guide will help you learn how to integrate custom components with MantineProvider and how to add Styles API support.
Add Styles API support
You will need to use createStyles to add Styles API support to any component:
- Create
useStyles
hook that will be used in component with createStyles:
- Add styles to component with
useStyles
hook:
Done! Styles API support was added to MyComponent
. You can now
set classNames
, styles
and other system props:
You can also add styles
and classNames
on MantineProvider:
Add default props support
You can add default props support to any component with
useComponentDefaultProps
hook:
Then you will be able to add default props on MantineProvider:
DefaultProps type
DefaultProps
adds system props support (margin, padding, sx, unstyled, styles and classNames).
It accepts 2 types: styles names and styles params, both of them are optional.
When you build components there might be 4 cases: