Default props
You can define default props for every Mantine component by setting theme.components.
These props will be used by default by all components of your application unless they are overridden by component props:
Default props with MantineThemeProvider
You can also use MantineThemeProvider to define default props
for a part of your application:
Default props for compound components
Some components like Menu and Tabs have associated compound components:
Menu.Item, Tabs.List, etc.. You can add default props to these components by omitting the dot from component name:
useProps hook
You can use useProps hook to add default props support to any custom component.
useProps accepts three arguments:
- component name (string) – it is used to connect component with theme
defaultProps– default props on component level – these props are used when default props are not defined on themeprops– props passed to component
Default color
Provider color
Prop color
withProps function
All Mantine components have withProps static function that can be used to
add default props to the component: