Breaking changes
- Mantine was migrated to emotion from react-jss and no longer supports react-jss
@mantine/corepackage no longer exports react-jssthemingcontext, use createStyles instead- All components no longer support
themeOverrideprop due to performance reasons elementRefprop was replaced withrefin all components- Default line-height (
theme.lineHeight) was increased from 1.4 to 1.55 - Default Container sizes were changed
- Divider component no longer supports
marginsprop, usemxormyinstead createStylesfunction now returns an object of{ classes, cx }instead of justclasses
Migration to emotion
Mantine no longer uses react-jss, all components were migrated to emotion based css-in-js library
exposed as separate @mantine/styles package and as a part of @mantine/core. This means that you will have to:
- migrate all of your custom styles built with react-jss to new
createStyleshook creator - setup new strategy for server side rendering
createStyles
Read createStyles documentation
From version 3.0 createStyles is the main way to add styles to Mantine components. Core features:
- API is similar to react-jss
- As fast and lightweight as emotion:
createStylesextends @emotion/react - Subscribes to your Mantine theming context
- Supports all emotion features: automatic critical css extraction during server side rendering, lazy evaluation, dynamic theming, etc.
- Server side rendering support: Next.js, Gatsby or any other environment
- Fully featured TypeScript support
Basic createStyles usage example:
Server side rendering
Since Mantine now uses emotion instead of react-jss you will need to change server side rendering strategy. Mantine now has 3 new packages to help you setup server side rendering:
@mantine/ssr– general server side rendering utilities@mantine/next– Next.js specific ssr configurationsgatsby-plugin-mantine– enable ssr in Gatsby
Follow these guides to get started with ssr:
Ref forwarding
All components that previously used elementRef were rebuilt with React.forwardRef, use ref prop to access element ref:
Unique ids during ssr
It's no longer required to set static ids on Grid, Menu, all inputs and some other components if you wrap your application in MantineProvider.
ColorSchemeProvider
ColorSchemeProvider is a new component that will help you manage color scheme (read full docs):
Margin props
All components now support setting following props to control margins:
m– setsmarginproperty on root elementmy– setsmargin-topandmargin-bottomproperties on root elementmx– setsmargin-rightandmargin-leftproperties on root elementmt– setsmargin-topproperty on root elementmb– setsmargin-bottomproperty on root elementml– setsmargin-leftproperty on root elementmr– setsmargin-rightproperty on root element
@mantine/dropzone package
@mantine/dropzone is a new package that includes Dropzone and FullScreenDropzone components.
Dropzone components lets you capture files from user with drag 'n' drop:
FullScreenDropzone works the same way as dropzone but instead of capturing dropped files from specific area it uses browser window as dropzone:
New components
MediaQuery component provides a simple API to manage breakpoints in jsx:
New features
Select and MultiSelect components now support creating new items, items grouping and disabling:
Accordion component now supports more options to customize icons and labels:
iconPositionprop let's you choose where chevron icon will be rendered: right or left- with
iconprop on Accordion and Accordion.Item components you can replace icons of all items at once or of each item individually
Avatar component now supports stacking with AvatarsGroup:
New hooks
use-resize-observer lets you subscribe to element size and position changes with ResizeObserver:
{
"x": 0,
"y": 0,
"width": 0,
"height": 0,
"top": 0,
"left": 0,
"bottom": 0,
"right": 0
}use-viewport-size hook returns viewport width and height:
use-mouse hook tracks mouse position over given element:
{ x: 0, y: 0 }use-hover hook detects if mouse is over given element:
Other changes
- ActionIcon and Button components now support new
defaultvariant - Pagination component now supports adding first and last controls and removing next/prev buttons
- SimpleGrid component now supports
theme.breakpointsusage inbreakpointsprop - SimpleGrid was migrated to use CSS Grid Layout instead of flexbox
- Group component no longer supports Styles API, you can add styles directly to element and children instead
- New Space component lets you add spacing between elements without directly subscribing to theme
- Overlay and LoadingOverlay components now support
radiusprop