Usage with TypeScript
Mantine exports types for every component, this guide will help you understand how to use and extend them.
Components props types
Each @asuikit/
package that exports components, exports props types for these components as well.
You can import component props types by adding Props
to the component name, for example, you can import
Button and DatePicker components props like so:
Styles names
Each component that supports Styles API exports type with selectors that can be used in classNames
and styles
props.
To import these types add StylesNames
to the component name:
Selectors type
Selectors
type extracts styles names from useStyles hook:
MantineTheme type
Use MantineTheme
type when theme type cannot be inferred, for example when you want to accept Mantine theme as an argument of a function:
Other exported types
Other types exported from @asuikit/core
package:
MantineSize
–'xs' | 'sm' | 'md' | 'lg' | 'xl'
MantineNumberSize
–'xs' | 'sm' | 'md' | 'lg' | 'xl' | number
MantineShadow
–MantineSize | (string & {})
MantineGradient
–{ from: string; to: string; deg?: number; }
MantineColor
– key of theme.colorsColorScheme
–'light' | 'dark'
Polymorphic components type
Polymorphic components require passing a type if you need to use props that require callback functions: