Releases: mantinedev/mantine
4.0.2
- Menu component was migrated to context, it no longer parses children – Menu.Item, Menu.Label components can now be wrapped with other components and stored in fragments
- List component was migrated to context – same new options are available for List.Item as for Menu.Item
- NextLink component was added to
@mantine/next
package to simplify Next.js Link usage with Menu
4.0.1
4.0.0
View changelog with demos on Mantine website
Mantine UI
Mantine UI is a new project with set of more than 120 responsive components built with Mantine.
All components support dark/light color scheme and Mantine theme customizations.
Mantine UI is free for everyone.
Breaking changes
@mantine/core
package no longer exportsCONTAINER_SIZES
variable- Prism now trims code by default, to disable that set
<Prism trim={false} />
useForm
hook exported from@mantine/hooks
package is now deprecated, it will be removed in one of the next releases.- @mantine/eslint-config was migrated to eslint-config-mantine
Renamed props
Some props were renamed to make Mantine components more consistent:
- Dialog, Card, Paper, Header and Navbar
padding
→p
- Container
padding
→px
- Radio
children
→label
- RadioGroup:
variant
→orientation
- Tooltip:
delay
→closeDelay
- Popover:
noClickOutside
→closeOnClickOutside
noFocusTrap
→trapFocus
noEscape
→closeOnEscape
- Modal:
noFocusTrap
→trapFocus
hideCloseButton
→withCloseButton
- Drawer:
noFocusTrap
→trapFocus
hideCloseButton
→withCloseButton
noOverlay
→withOverlay
noCloseOnEscape
→closeOnEscape
noCloseOnClickOutside
→closeOnClickOutside
noScrollLock
→lockScroll
Default props on MantineProvider
Most of components now support default props on MantineProvider:
import { MantineProvider, Button } from '@mantine/core';
function App() {
return (
<MantineProvider
defaultProps={{
Button: { color: 'red' },
Badge: { size: 'xl', radius: 0 },
// ... default props for other components
}}
>
{/* By default, Button will have red color */}
<Button>Red button</Button>
{/* Default color can be overwritten by props */}
<Button color="blue">Blue button</Button>
{/* By default, Badge will have xl size and 0 radius */}
<Badge>Badge</Badge>
</MantineProvider>
);
}
Styles params on MantineProvider
You can now get component styles params in MantineProvider styles
prop.
Each component that has Styles API now exports type that can be assigned to params
ComponentNameStylesParams
, for example, ButtonStylesParams
. This feature can be used to add more complex context styles that were not possible before:
import { MantineProvider, ButtonStylesParams } from '@mantine/core';
function Demo() {
return (
<MantineProvider
styles={{
Button: (theme, params: ButtonStylesParams) => ({
root: {
// use params to calculate dynamic styles
color: theme.colors[params.color || theme.primaryColor][1],
padding: params.size === 'lg' ? '15px 45px' : undefined,
},
}),
}}
/>
);
}
Nested MantineProvider inheritance
Nested MantineProviders will now inherit theme
override, emotionOptions
, defaultProps
and styles
from
parent provider if inherit
prop is set:
import { MantineProvider, Button } from '@mantine/core';
function App() {
return (
// Parent MantineProvider
<MantineProvider
theme={{ colorScheme: 'dark' }}
styles={{ Button: { root: { fontWeight: 400 } } }}
defaultProps={{ Badge: { variant: 'outline' } }}
emotionOptions={{ key: 'custom-cache' }}
>
<Button>Affected only by parent provider</Button>
{/*
Child MantineProvider, inherits theme, emotionOptions, defaultProps and styles
from parent MantineProvider. Other properties specified on child provider will override parent props.
For example, theme override will be: { colorScheme: 'dark', primaryColor: 'red' }
*/}
<MantineProvider theme={{ primaryColor: 'red' }} inherit>
<Button>Affected only by child provider</Button>
</MantineProvider>
</MantineProvider>
);
}
Default radius and focus ring configuration on theme
Mantine theme now includes two new properties: defaultRadius
and focusRing
.
defaultRadius
property is used to set border-radius on most components by default:
import { MantineProvider, Button } from '@mantine/core';
function App() {
return (
<MantineProvider theme={{ defaultRadius: 0 }}>
<Button>Zero radius button</Button>
<Button radius="xl">xl radius button</Button>
</MantineProvider>
);
}
With focusRing
property you can configure how focus ring is displayed:
auto
– display focus ring only when user navigates with keyboard (default)always
– display focus ring when user navigates with keyboard and mousenever
– focus ring is always hidden (not recommended)
import { MantineProvider, Button } from '@mantine/core';
function App() {
return (
<MantineProvider theme={{ focusRing: 'always' }}>
<Button>Focus ring will be displayed when user clicks the button</Button>
</MantineProvider>
);
}
Padding props
All components now support setting following props to control padding:
p
– setspadding
property on root elementpy
– setspadding-top
andpadding-bottom
properties on root elementpx
– setspadding-right
andpadding-left
properties on root elementpt
– setspadding-top
property on root elementpb
– setspadding-bottom
property on root elementpl
– setspadding-left
property on root elementpr
– setspadding-right
property on root element
import { Paper, Container } from '@mantine/core';
function Demo() {
return (
<>
<Paper p={20} />
<Container px="xl" />
</>
);
}
createStyles references changes
createStyles function now works differently with references.
Instead of generating unique identifiers with each getRef
call it returns the same value for given argument:
// before 4.0.0
// getRef('icon') !== getRef('icon')
createStyles((theme, params, getRef) => {
const icon = getRef('icon');
return {
icon: { ref: icon },
parent: {
[`& .${icon}`]: { color: 'red' },
},
};
});
// in 4.0.0
// getRef('icon') === getRef('icon')
createStyles((theme, params, getRef) => ({
icon: { ref: getRef('icon') },
parent: {
[`& .${getRef('icon')}`]: { color: 'red' },
},
}));
@mantine/form package
New @mantine/form package is an enhanced version of useForm
hook that was previously exported from
@mantine/hooks
package. @mantine/form
introduces the following features:
- Improved fields validation logic
- Schema based validation with zod, yup or joi
- Array fields support
@mantine/spotlight package
@mantine/spotlight is a new package that lets you create
a command center for your application. It can be triggered with keyboard shortcut and programmatically
from anywhere in your application.
New components
New features
- NumberInput component now supports
formatter
andparser
props to customize how value is displayed in the input - Tooltip component now supports
openDelay
- Slider and RangeSlider components now support
onChangeEnd
prop - Overlay component now supports
blur
- New use-disclosure hook
- Text component now inherits color from parent element
- Input component now handles
required
prop differently to support native browser validation - RichTextEditor now supports providing extra quill modules via
modules
prop - DateRangePicker now displays first selected date
- RangeCalendar now calls onChange with first selected date
- SegmentedControl component now supports vertical orientation and disabled state
- ThemeIcon component now supports outline variant
- Text, Anchor and Highlight components now support
underline
prop - Container component now supports sizes configuration with default props on MantineProvider
- All components now support negative margins for theme values with margin props (
m
,mx
,my
...
3.6.14
3.6.13
3.6.12
- Add option to configure modal z-index in DatePicker and DateRangePicker components
- Fix click outside events not working for DatePicker and DateRangePicker when used in Modal and Drawer
- Add missing required attribute to PasswordInput
- Fix disabled and clearable props combination in Select and MultiSelect components (#908)
3.6.11
3.6.10
- Fix incorrect font-size applied to body element (#849)
- Fix onDropdownOpen callback called each time value when value changes (#858)
- Add option to override position in Portal component (#845)
- Fix Avatar
src
prop type to supportnull
(#865) - Fix datesLocale not being consumed from MantineProvider in DateRangePicker component (#868)
- Fix callback running twice when leaving scrollbar in use-page-leave hook (#891)
3.6.9
3.6.8
- Add
onDropdownOpen
andonDropdownClose
props support to DatePicker and DateRangePicker components - Fix incorrect modal size for multiple months in DatePicker and DateRangePicker components
- Add missing right and bottom padding to AppShell component
- Fix
initialLevel
prop not working in DateRangePicker component - Fix incorrect
openRef
type in Dropzone component - Add option to overwrite
autocomplete
attribute on Select component - Add correct input mode to NumberInput – mobile devices will display correct keyboard now