Releases: mantinedev/mantine
7.4.1
What's Changed
[@mantine/core]
Combobox: Fix numpad enter not working (#5526)[@mantine/core]
Combobox: FixonClose
prop not working (#5509)[@mantine/core]
AppShell: Fix header height 0 not working (#5514)[@mantine/core]
ColorPicker: Fix incorrect background gradient in AlphaSlider (#5518)[@mantine/core]
Indicator: FixautoContrast
being passed to the dom node as attribute (#5508)[@mantine/core]
NumberInput: FixallowLeadingZeros
prop not working[@mantine/core]
NumberInput: Fix incorrect controls border color in disabled state[@mantine/core]
NumberInput: Fix incorrect -0.0, -0.00, -0.000 ... inputs handling[@mantine/core]
Popover: Improvewidth
prop type[@mantine/core]
Improve types ofdata
prop in Autocomplete and TagsInput components[@mantine/core]
MultiSelect: Fixrequired
prop not displaying required asterisk[@mantine/hooks]
use-scroll-into-view: Improve types (#5426)[@mantine/core]
MultiSelect: Fix incorrectpointer-events
style on the right section (#5472)[@mantine/core]
Fix breakpoints defined in px being transformed into em whenvisibleFrom
andhiddenFrom
props are used (#5457)[@mantine/core]
Rating: Improvesize
type (#5470)[@mantine/core]
ScrollArea: Fix ScrollArea.Autosize working incorrectly with some tables (#5481)[@mantine/core]
NumberInput: Add support for numbers that are larger than Number.MAX_SAFE_INTEGER (#5471)[@mantine/core]
Combobox: Fix readonly data array not being supported (#5477)[@mantine/charts]
Fix incorrect y-axis styles in RTL (#5505)
New Contributors
- @hexcowboy made their first contribution in #5477
- @giveerr made their first contribution in #5471
- @ayovev made their first contribution in #5481
- @hirotomoyamada made their first contribution in #5518
- @buzzthedev made their first contribution in #5535
- @ID-JA made their first contribution in #5509
Full Changelog: 7.4.0...7.4.1
7.4.0 β
View changelog with demos on mantine.dev website
@mantine/charts
New @mantine/charts package provides a set of components
to build charts and graphs. All components are based on recharts.
Currently, the package provides AreaChart, BarChart,
LineChart and Sparkline components.
More components will be added in the next minor releases.
AreaChart component
New AreaChart component:
import { AreaChart } from '@mantine/charts';
import { data } from './data';
function Demo() {
return (
<AreaChart
h={300}
data={data}
dataKey="date"
type="stacked"
series={[
{ name: 'Apples', color: 'indigo.6' },
{ name: 'Oranges', color: 'blue.6' },
{ name: 'Tomatoes', color: 'teal.6' },
]}
/>
);
}
LineChart component
New LineChart component:
import { LineChart } from '@mantine/charts';
import { data } from './data';
function Demo() {
return (
<LineChart
h={300}
data={data}
dataKey="date"
withLegend
series={[
{ name: 'Apples', color: 'indigo.6' },
{ name: 'Oranges', color: 'blue.6' },
{ name: 'Tomatoes', color: 'teal.6' },
]}
/>
);
}
BarChart component
New BarChart component:
import { BarChart } from '@mantine/charts';
import { data } from './data';
function Demo() {
return (
<BarChart
h={300}
data={data}
dataKey="month"
type="stacked"
orientation="vertical"
yAxisProps={{ width: 80 }}
series={[
{ name: 'Smartphones', color: 'violet.6' },
{ name: 'Laptops', color: 'blue.6' },
{ name: 'Tablets', color: 'teal.6' },
]}
/>
);
}
Sparkline component
New Sparkline component:
import { Sparkline } from '@mantine/charts';
function Demo() {
return (
<Sparkline
w={200}
h={60}
data={[10, 20, 40, 20, 40, 10, 50]}
curveType="linear"
color="blue"
fillOpacity={0.6}
strokeWidth={2}
/>
);
}
OKLCH colors support
You can now use OKLCH colors in theme.colors
.
OKLCH color model has 88.18% browser support,
it is supported in all modern browsers. OKLCH model provides 30% more colors than HSL model and
has several other advantages.
Example of adding OKLCH color to the theme:
import { Button, createTheme, Group, MantineProvider } from '@mantine/core';
const theme = createTheme({
colors: {
'oklch-blue': [
'oklch(96.27% 0.0217 238.66)',
'oklch(92.66% 0.0429 240.01)',
'oklch(86.02% 0.0827 241.66)',
'oklch(78.2% 0.13 243.83)',
'oklch(71.8% 0.1686 246.06)',
'oklch(66.89% 0.1986 248.32)',
'oklch(62.59% 0.2247 250.29)',
'oklch(58.56% 0.2209 251.26)',
'oklch(54.26% 0.2067 251.67)',
'oklch(49.72% 0.1888 251.59)',
],
},
});
function Demo() {
return (
<MantineProvider theme={theme}>
<Group>
<Button color="oklch-blue">Filled</Button>
<Button color="oklch-blue" variant="outline">
Outline
</Button>
<Button color="oklch-blue" variant="light">
Light
</Button>
</Group>
</MantineProvider>
);
}
autoContrast
New theme.autoContrast
property controls whether text color should be changed based on the given color
prop
in the following components:
- ActionIcon with
variant="filled"
only - Alert with
variant="filled"
only - Avatar with
variant="filled"
only - Badge with
variant="filled"
only - Button with
variant="filled"
only - Chip with
variant="filled"
only - NavLink with
variant="filled"
only - ThemeIcon with
variant="filled"
only - Checkbox with
variant="filled"
only - Radio with
variant="filled"
only - Tabs with
variant="pills"
only - SegmentedControl
- Stepper
- Pagination
- Progress
- Indicator
- Timeline
- Spotlight
- All @mantine/dates components that are based on Calendar component
autoContrast
can be set globally on the theme level or individually for each component via autoContrast
prop,
except for Spotlight and @mantine/dates components, which only support global theme setting.
import { Button, Code, Group } from '@mantine/core';
function Demo() {
return (
<>
<Code>autoContrast: true</Code>
<Group mt="xs" mb="lg">
<Button color="lime.4" autoContrast>
Lime.4 button
</Button>
<Button color="blue.2" autoContrast>
Blue.2 button
</Button>
<Button color="orange.3" autoContrast>
Orange.3 button
</Button>
</Group>
<Code>autoContrast: false</Code>
<Group mt="xs">
<Button color="lime.4">Lime.4 button</Button>
<Button color="blue.2">Blue.2 button</Button>
<Button color="orange.3">Orange.3 button</Button>
</Group>
</>
);
}
autoContrast
checks whether the given color luminosity is above or below the luminanceThreshold
value
and changes text color to either theme.white
or theme.black
accordingly:
import { Button, createTheme, MantineProvider, Stack } from '@mantine/core';
const theme = createTheme({
autoContrast: true,
luminanceThreshold: 0.3,
});
function Wrapper(props: any) {
const buttons = Array(10)
.fill(0)
.map((_, index) => (
<Button key={index} color={`blue.${index}`}>
Button
</Button>
));
return (
<MantineProvider theme={theme}>
<Stack>{buttons}</Stack>
</MantineProvider>
);
}
Color functions improvements
alpha
, lighten
and darken
functions now support CSS variables (with color-mix) and OKLCH colors.
All functions are available both in @mantine/core
(.ts
/.js
files) and postcss-preset-mantine (.css
files, requires version 1.12.0 or higher).
In .css
files:
.demo-alpha {
color: alpha(var(--mantine-color-red-4), 0.5);
border: 1px solid alpha(#ffc, 0.2);
}
.demo-lighten-darken {
color: lighten(var(--mantine-color-red-4), 0.5);
border: 1px solid darken(#ffc, 0.2);
}
Will be transformed to:
.demo-alpha {
color: color-mix(in srgb, var(--mantine-color-red-4), transparent 50%);
border: 1px solid color-mix(in srgb, #ffc, transparent 80%);
}
.demo-lighten-darken {
color: color-mix(in srgb, var(--mantine-color-red-4), white 50%);
border: 1px solid color-mix(in srgb, #ffc, black 20%);
}
In .ts
/.js
files:
import { alpha, lighten } from '@mantine/core';
alpha('#4578FC', 0.45); // -> rgba(69, 120, 252, 0.45)
alpha('var(--mantine-color-gray-4)', 0.74);
// -> color-mix(in srgb, var(--mantine-color-gray-4), transparent 26%)
lighten('#4578FC', 0.45); // -> #a3c1ff
lighten('var(--mantine-color-gray-4)', 0.74);
// -> color-mix(in srgb, var(--mantine-color-gray-4), white 74%)
Note that alpha
function is a replacement for rgba
. It was renamed to
have a more clear meaning, as it can now be used with CSS variables and OKLCH colors.
rgba
function is still available as an alias for alpha
function.
enhanceGetInputProps
@mantine/form
now supports enhanceGetInputProps. enhanceGetInputProps
is a function that can be used to add additional props to the object returned by form.getInputProps
.
You can define it in useForm
hook options. Its argument is an object with the following properties:
inputProps
β object returned byform.getInputProps
by defaultfield
β field path, first argument ofform.getInputProps
, for examplename
,user.email
,users.0.name
options
β second argument ofform.getInputProps
, for example{ type: 'checkbox' }
, can be used to pass additional
options toenhanceGetInputProps
functionform
β form instance
Example of using enhanceGetInputProps
to disable input based on field path:
import { NumberInput, TextInput } from '@mantine/core';
import { useForm } from '@mantine/form';
interface FormValues {
name: string;
age: number | string;
}
function Demo() {
const form = useForm<FormValues>({
initialValues: { name: '', age: '' },
enhanceGetInputProps: (payload) => ({
disabled: ...
7.3.2
What's Changed
[@mantine/core]
Portal: Fix empty className string throwing error (#5400)[@mantine/core]
Select: Fix incorrect empty string as initial value handing[@mantine/core]
Fix error thrown in jest tests when autosize Textarea is used in Next.js application (#5393)[@mantine/core]
Loader: Fix default loaders not being available if custom loader was default with defaultProps on theme[@mantine/core]
Chip: Fixcolor
prop not working without specifying variant[@mantine/core]
MultiSelect: Fix dropdown not being opened when Space key is pressed and the component is not searchable[@mantine/core]
NavLink: Add missing Space key handling for collapse/expand nested links[@mantine/dates]
DateInput: Fix incorrect clear button size[@mantine/core]
Fix text inside MultiSelect, TagsInput and PillsInput search field not being possible to select with mouse[@mantine/core]
Set cursor tonot-allowed
on disabled Checkbox, Radio and Switch[@mantine/core]
NumberInput: Improve disabled increment/decrement controls styles[@mantine/core]
Button: Fix incorrect alignment if button is used in the same container as other buttons withcomponent
prop[@mantine/core]
SegmentedControl: Improve readOnly styles[@mantine/core]
NumberInput: Fix incorrect controls text color in error state[@mantine/core]
Change divs to more semantic elements in Modal and Drawer[@mantine/core]
Make header height of Modal and Drawer consistent to prevent layout shift whenwithCloseButton
prop is changed[@mantine/core]
FixonChange
not being called in Radio, Checkbox and Chip components if they are used insideX.Group
[@mantine/core]
NumberInput: Fix incorrect negative decimal values input handing[@mantine/core]
Button: Fix incorrect Loader vertical alignment[@mantine/vanilla-extract]
Expose all primary colors values[@mantine/core]
Menu: Fix incorrect aria roles (#5372)[@mantine/core]
Table: Fix sticky header being overlayed by elements in table rows in some cases (#5385)[@mantine/core]
Combobox: FixrightSection
andleftSection
nor being visible onCombobox.Search
(#5368)[@mantine/core]
Tabs: Fix clipped border of outline variant (#5370)[@mantine/core]
Fix incorrectrightSectionPointerEvents
in Select and MultiSelect components (#5371)[@mantine/core]
Alert: Fix incorrect margin if title is hidden[@mantine/core]
Overlay: Fix blur styles not working in old Safari
New Contributors
- @abdulbasithqb made their first contribution in #5385
Full Changelog: 7.3.1...7.3.2
7.3.1
What's Changed
[@mantine/core]
Fix broken default colors override[@mantine/core]
Menu: Improveclick-hover
trigger accessibility (#5335)[@mantine/core]
Fix incorrectlineHeight
theme variables resolving (#5375)[@mantine/core]
Select: Fix error thrown if google translate changes labels (#5377)[@mantine/tiptap]
Add missingcontrol
Styles API selector toRichTextEditor.Link
(#5171)[@mantine/core]
Grid: Fix incorrect Grid.Col auto span handing if one Grid is used inside another Grid (#5278)[@mantine/core]
Grid: Fix incorrect Grid.Col styles when the column isauto
as base value andcontent
as breakpoint value (#5280)[@mantine/core]
Fix various RTL issues (#5250)[@mantine/dates]
FixhideOutsideDates
now working if@mantine/dates
is used as a headless library (#5003)[@mantine/core]
SegmentedControl: Remove animation during initialization (#5182)[@mantine/core]
Menu: Fix broken focus logic whenkeepMounted
is set (#4502)[@mantine/tiptap]
Remove@tabler/icons
dependency to improve bundling performance (#5279)[@mantine/core]
Fix inputs have incorrect left and right sections colors in error state (#5304)[@mantine/core]
Title: AddlineClamp
support (#5321)[@mantine/core]
Grid: Change default overflow to visible (#5276)[@mantine/core]
ScrollArea: Fix incorrect scrollbars styles (#4904)[@mantine/core]
Expose--mantine-primary-color-x
CSS variables (#5331)[@mantine/core]
Combobox: Fix incorrect Enter key handling when dropdown is opened and option is not selected (#5348)[@mantine/core]
NumberInput: FixstartValue
nor working ifmin
is set (#5308)[@mantine/core]
Collapse: Add missing Collapse.extend function (#5313)[@mantine/core]
Fix incorrect clamp() function handing in style props (#5330)[@mantine/core]
PinInput: Trim value on paste before validation (#5340)[@mantine/core]
PinInput: Fix incorrectly assigned ref (#5365)[@mantine/core]
Remove use client from createPolymorphicComponent factory (#5367)
New Contributors
- @manuelbosi made their first contribution in #5377
- @riettsruff made their first contribution in #5375
Full Changelog: 7.3.0...7.3.1
7.3.0 π
View changelog with demos on mantine.dev website
smaller-than and larger-than mixins
smaller-than
and larger-than
mixins can be used to create styles that will be applied only when the screen is smaller or larger than specified breakpoint.
Note that to use these mixins, you need to update postcss-preset-mantine to version 1.11.0
or higher.
.demo {
@mixin smaller-than 320px {
color: red;
}
@mixin larger-than 320px {
color: blue;
}
}
Will be transformed to:
// Breakpoint values are converted to em units
// In smaller-than mixin 0.1px is subtracted from breakpoint value
// to avoid intersection with larger-than mixin
@media (max-width: 19.99375em) {
.demo {
color: red;
}
}
@media (min-width: 20em) {
.demo {
color: blue;
}
}
You can also use smaller-than
and larger-than
mixins with mantine breakpoints:
.demo {
@mixin smaller-than $mantine-breakpoint-sm {
color: red;
}
@mixin larger-than $mantine-breakpoint-sm {
color: blue;
}
}
Form schema resolvers packages
@mantine/form
schema validation resolver packages are now available as separate packages.
Moving resolvers to separate packages allows making them type-safe and fully tested.
Old resolvers are still exported from @mantine/form
package β you will be able to use them without any changes
until 8.0.0 release.
The new packages are drop-in replacements for old resolvers, they have the same API and can be used in the same way.
Example of zod resolver:
yarn add zod mantine-form-zod-resolver
import { z } from 'zod';
import { useForm } from '@mantine/form';
import { zodResolver } from 'mantine-form-zod-resolver';
const schema = z.object({
name: z.string().min(2, { message: 'Name should have at least 2 letters' }),
email: z.string().email({ message: 'Invalid email' }),
age: z.number().min(18, { message: 'You must be at least 18 to create an account' }),
});
const form = useForm({
initialValues: {
name: '',
email: '',
age: 16,
},
validate: zodResolver(schema),
});
form.validate();
form.errors;
// -> {
// name: 'Name should have at least 2 letters',
// email: 'Invalid email',
// age: 'You must be at least 18 to create an account'
// }
rem/em functions improvements
rem and em function now support space-separated values. This feature is available
both in rem
function exported from @mantine/core
package and postcss-preset-mantine.
Note that you need to update postcss-preset-mantine to 1.11.0
to use this feature.
import { rem } from '@mantine/core';
rem('16px 32px');
// -> calc(1rem * var(--mantine-scale)) calc(2rem * var(--mantine-scale))
All components props that are converted to rem
units now support space-separated values as well.
For example, space-separated values can be used in radius
prop of Modal component:
import { Modal } from '@mantine/core';
function Demo() {
return <Modal radius="10px 10px 0 0" opened onClose={() => {}} />;
}
component and renderRoot props for non-polymorphic components
All Mantine components now support component
and renderRoot
props event if they are not polymorphic.
The difference between polymorphic and non-polymorphic components is that polymorphic components
include the full set of props of the component passed to the component
prop, while non-polymorphic
components only include props that are specific to the original component. It is done this way to
improve TypeScript performance.
import { Group } from '@mantine/core';
// Group is not polymorphic component,
// but it still supports component and renderRoot props
function Demo() {
return (
<Group component="nav">
<a>Item 1</a>
<a>Item 2</a>
<a>Item 3</a>
</Group>
);
}
Outline Checkbox and Radio variant
Checkbox and Radio components now support outline
variant:
import { Radio, Checkbox, Stack } from '@mantine/core';
function Demo() {
return (
<Stack gap={7}>
<Checkbox variant="outline" label="Outline Checkbox" defaultChecked />
<Checkbox variant="outline" label="Outline indeterminate Checkbox" indeterminate />
<Radio variant="outline" label="Outline Radio" defaultChecked />
</Stack>
);
}
HueSlider and AlphaSlider components
HueSlider and AlphaSlider components were added back:
import { useState } from 'react';
import { HueSlider, Text } from '@mantine/core';
function Demo() {
const [value, onChange] = useState(250);
return (
<>
<Text>Hue value: {value}</Text>
<HueSlider value={value} onChange={onChange} />
</>
);
}
import { useState } from 'react';
import { AlphaSlider, Text } from '@mantine/core';
function Demo() {
const [value, onChange] = useState(0.55);
return (
<>
<Text>Alpha value: {value}</Text>
<AlphaSlider color="#1c7ed6" value={value} onChange={onChange} />
</>
);
}
Button loading state animation
Button component now has loading state animation:
import { Button, Group } from '@mantine/core';
function Demo() {
const [loading, { toggle }] = useDisclosure();
return (
<>
<Group>
<Button loading={loading}>Filled button</Button>
<Button variant="light" loading={loading}>
Light button
</Button>
<Button variant="outline" loading={loading}>
Outline button
</Button>
</Group>
<Switch checked={loading} onChange={toggle} label="Loading state" mt="md" />
</>
);
}
Drawer offset
Drawer now supports offset
prop. It changes drawer offset from the edge of the viewport:
import { useDisclosure } from '@mantine/hooks';
import { Drawer, Button } from '@mantine/core';
function Demo() {
const [opened, { open, close }] = useDisclosure(false);
return (
<>
<Drawer offset={8} radius="md" opened={opened} onClose={close} title="Authentication">
{/* Drawer content */}
</Drawer>
<Button onClick={open}>Open Drawer</Button>
</>
);
}
z-index CSS variables
You can now use Mantine z-index CSS variables:
--mantine-z-index-app
β value100
--mantine-z-index-modal
β value200
--mantine-z-index-popover
β value300
--mantine-z-index-overlay
β value400
--mantine-z-index-max
β value9999
Example of using --mantine-z-index-modal
variable:
/* Display content above the modal */
.my-content {
z-index: calc(var(--mantine-z-index-modal) + 1);
}
Improved dark color scheme colors
theme.colors.dark
colors were slightly changed to improve contrast and make it easier to read text.
You can preview new colors on this page. New colors values are:
--mantine-color-dark-0: #c9c9c9;
--mantine-color-dark-1: #b8b8b8;
--mantine-color-dark-2: #828282;
--mantine-color-dark-3: #696969;
--mantine-color-dark-4: #4a4a4a;
--mantine-color-dark-5: #404040;
--mantine-color-dark-6: #383838;
--mantine-color-dark-7: #2e2e2e;
--mantine-color-dark-8: #242424;
--mantine-color-dark-9: #212121;
If you prefer old colors, change theme settings on MantineProvider
:
import { createTheme } from '@mantine/core';
const theme = createTheme({
colors: {
dark: [
'#C1C2C5',
'#A6A7AB',
'#909296',
'#5c5f66',
'#373A40',
'#2C2E33',
'#25262b',
'#1A1B1E',
'#141517',
'#101113',
],
},
});
function Demo() {
return <MantineProvider theme={theme}>{/* Your app here */}</MantineProvider>;
}
Documentation updates
- Schema-based validation with
@mantine/form
now has a dedicated page. It includes more examples for basic, nested and list fields validation for each resolver. - Autocomplete, Select, MultiSelect and TagsInput now include new demos that show how to customize dropdown behavior and styles.
- Example of using Mantine with disabled JavaScript was added to the color schemes guide.
- Pagination now includes an additional example with chunked content handling.
- A new section about dayjs localization with Next.js app router and server components has been added to the dates getting started page
- Modals manager now includes a guide on how to pass props down to the underlying Modal component.
- Slider now has sections about decimal values and
minRange
prop. - You can now view all 200+ releases with release dates on the all releases page.
Other changes
- [use-has...
7.2.2
What's new
[@mantine/core]
HoverCard: Removeopened
andonChange
props from types[@mantine/core]
RingProgress: Fix error thrown when thickness is larger thansize / 4
[@mantine/dates]
DateInput: Fix unexpected values updates when the user tries to type in value with closed dropdown (#3818)[@mantine/core]
NumberInput: FixonChange
called when value is changed by external state (#5235)[@mantine/core]
NumberInput: FixonChange
function called inonBlur
when the value does not require updating[@mantine/core]
NumberInput: ImproveonChange
handler to be called with number unless the input is empty (#5037)[@mantine/core]
SegmentedControl: Fix incorrect indicator position if padding is set on the root element[@mantine/core]
Select: Fix empty string not being handled correctly as option value[@mantine/core]
Blockquote: Fix incorrectborder-radius
[@mantine/core]
Chip: Fix incorrect disabled styles in dark color scheme[@mantine/core]
Table: Setbackgound-color
onthead
only ifstrickyHeader
prop is set[@mantine/core]
Radio: Fix radio icon size being the same width and height at every size[@mantine/tiptap]
Fix incorrect rtl controls styles (#5223)[@mantine/tiptap]
Fix unexpected background-color set oncode
element
7.2.1
What's Changed
[@mantine/core]
Numberinput: Reduce width of the right section to match controls width (#5033)[@mantine/core]
Popover: Addsize
floating-ui middleware to prevent large dropdown from exceeding screen size (#5213)[@mantine/code-highlight]
Prevent error thowing if language is not recognized by highlight.js (#5099)[@mantine/notifications]
Fixlimit
prop not working (#5105)[@mantine/dropzone]
Allow overriding props from react-dropzone-esm with component props (#5114)[@mantine/core]
Remove"use client";
directive fromrem
,createTheme
and other utility theme functions (#5119)[@mantine/hooks]
use-hash: Add option to retrieve value initially withoutuseEffect
(#5140)[@mantine/core]
PasswordInput: Fix incorrect styles when the component is wrapper with element withdata-disabled
attribute (#5149)[@mantine/core]
Add support for values separated by space torem
andem
functions (#5174)[@mantine/code-highlight]
Fix CodeHighlightTabs throwing error if language of the tab is nor specified (#5178)[@mantine/core]
Fieldset: Fix some elements overflowing the viewport width when rendered inside fieldset (#5179)[@mantine/core]
Modal: Fix ScrollArea not working as scroll container (#5189)[@mantine/core]
Text: Fixinline
prop not working (#5194)[@mantine/core]
Alert: Fix incorrect styles when the component is used without children (#5196)[@mantine/core]
Setaria-hidden
on Checkbox and Radio icons to prevent them being announced by screen readers (#5202)[@mantine/form]
Fixform.reset
not reseting values to updatedinitialValues
(#5123)
New Contributors
- @kavinda1995 made their first contribution in #5145
- @dodas made their first contribution in #5123
- @gorkunov made their first contribution in #5194
- @ranquild made their first contribution in #5213
- @SecondThundeR made their first contribution in #5210
Full Changelog: 7.2.0...7.2.1
7.2.0 β
Community templates
You are welcome to share your GitHub templates with the community. Community templates are
featured on the getting started page. You can find a guide on how to
create and submit a template here.
Examples of templates that you can submit:
- Next.js pages router + MDX + Mantine blog template
- Next.js app router + Mantine + styled-components template
- Vite + Mantine + Emotion template
NumberFormatter component
New NumberFormatter component allows to format numbers
with thousands separators, decimal separators, and custom number of decimal places.
It supports the same formatting related props as NumberInput component.
import { NumberFormatter } from '@mantine/core';
function Demo() {
return <NumberFormatter prefix="$ " value={1000000} thousandSeparator />;
}
Form actions
@mantine/form
package now exports createFormActions
function that
can be used to change form state from anywhere in your application.
The mechanism of form actions is similar to notifications system,
modals manager and other similar packages.
To use form actions, set name
property in use-form settings:
import { useForm } from '@mantine/form';
export interface DemoFormValues {
name: string;
age: number;
}
function Demo() {
const form = useForm<DemoFormValues>({
name: 'demo-form',
initialValues: {
name: '',
age: 0,
},
});
}
Then call createFormActions
function with the same form name as specified in useForm
settings:
// Import type of form values from the file where you defined useForm
import type { DemoFormValues } from './DemoForm';
import { createFormActions } from '@mantine/form';
export const demoFormActions = createFormActions<DemoFormValues>('demo-form');
After that, you can use demoFormActions
to change form state from anywhere in your application.
For example, after a fetch request or after a user interaction with a component that does not have access
to the form state:
import { useEffect } from 'react';
import { Button } from '@mantine/core';
import { demoFormActions } from './demoFormActions';
function ExternalComponent() {
useEffect(() => {
fetch('/api/user')
.then((res) => res.json())
.then((res) =>
demoFormActions.setValues({
name: res.name,
age: res.age,
})
);
}, []);
return <Button onClick={() => demoFormActions.reset()}>Reset demo form</Button>;
}
Table data prop
Table component now supports data
prop which can be used to generate table rows
from given data:
import { Table, TableData } from '@mantine/core';
const tableData: TableData = {
caption: 'Some elements from periodic table',
head: ['Element position', 'Atomic mass', 'Symbol', 'Element name'],
body: [
[6, 12.011, 'C', 'Carbon'],
[7, 14.007, 'N', 'Nitrogen'],
[39, 88.906, 'Y', 'Yttrium'],
[56, 137.33, 'Ba', 'Barium'],
[58, 140.12, 'Ce', 'Cerium'],
],
};
function Demo() {
return <Table data={tableData} />;
}
Table sticky header
Table component now supports stickyHeader
prop, which can be used to make the table header
stick to the top of the table:
import { Table } from '@mantine/core';
const elements = [
{ position: 6, mass: 12.011, symbol: 'C', name: 'Carbon' },
{ position: 7, mass: 14.007, symbol: 'N', name: 'Nitrogen' },
{ position: 39, mass: 88.906, symbol: 'Y', name: 'Yttrium' },
{ position: 56, mass: 137.33, symbol: 'Ba', name: 'Barium' },
{ position: 58, mass: 140.12, symbol: 'Ce', name: 'Cerium' },
];
function Demo() {
const rows = elements.map((element) => (
<Table.Tr key={element.name}>
<Table.Td>{element.position}</Table.Td>
<Table.Td>{element.name}</Table.Td>
<Table.Td>{element.symbol}</Table.Td>
<Table.Td>{element.mass}</Table.Td>
</Table.Tr>
));
return (
<Table stickyHeader stickyHeaderOffset={60}>
<Table.Thead>
<Table.Tr>
<Table.Th>Element position</Table.Th>
<Table.Th>Element name</Table.Th>
<Table.Th>Symbol</Table.Th>
<Table.Th>Atomic mass</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>{rows}</Table.Tbody>
<Table.Caption>Scroll page to see sticky thead</Table.Caption>
</Table>
);
}
Usage with Sass
It is now possible to use Mantine with Sass. You can find documentation
on this page. Note that it is still required to set up postcss-preset-mantine
in order for all functions to work properly. Sass can be used as a replacement for CSS modules
β it supports all features that CSS modules support.
You can find examples of Mantine + Sass usage in separate branches of templates:
Inline loaders
Loader component now supports children
prop. The prop allows overriding the default
loader with any React node. It is useful in components that support loaderProps
(Button, LoadingOverlay, Dropzone, etc.)
β with loaderProps.children
you can now display any React node instead of the loader.
import { useDisclosure } from '@mantine/hooks';
import { LoadingOverlay, Button, Group, Box } from '@mantine/core';
function Demo() {
const [visible, { toggle }] = useDisclosure(false);
return (
<>
<Box pos="relative">
<LoadingOverlay visible={visible} loaderProps={{ children: 'Loading...' }} />
{/* ...other content */}
</Box>
<Group position="center">
<Button onClick={toggle}>Toggle overlay</Button>
</Group>
</>
);
}
lightHidden and darkHidden props
All Mantine components now support lightHidden
and darkHidden
props that can be used to hide
components in a specific color scheme:
import { Button } from '@mantine/core';
function Demo() {
return (
<>
<Button color="cyan" lightHidden>
Visible in dark color scheme only
</Button>
<Button color="pink" darkHidden>
Visible in light color scheme only
</Button>
</>
);
}
light-root and dark-root mixins
New light-root
and dark-root
mixins were added to postcss-preset-mantine.
These mixins can be used to add color scheme specific styles to the :root
/html
element.
Note that to use these mixins, you need to update postcss-preset-mantine
to 1.9.0
or higher.
:root {
@mixin light-root {
--color: red;
}
@mixin dark-root {
--color: blue;
}
}
Documentation updates
- New Styles overview guide
- New Usage with Sass guide
- Storybook guide was updated to use new @storybook/addon-styling-webpack with separate instructions for Vite and other frameworks
- CSS modules guide now includes new section about global class names reference with
:global
selector - Getting started guide now includes new section about setting up VS Code with PostCSS Language Support and CSS Variable Autocomplete extensions
- Popover documentation now includes a guide on how to use nested popovers
- AspectRatio documentation now includes a guide on how to use it in flexbox containers
- Additional AppShell.Section documentation was added
- 8 new Checkbox examples and demos were added
Other changes
- Dropzone now supports
loaderProps
prop to pass props down to the Loader component - theme.variantColorResolver now supports
hoverColor
prop, which allows controllingcolor
property when the component is hovered. New property is supported in Button and ActionIcon components. - Flex is now a polymorphic component β it accepts
renderRoot
andcomponent
props - Checkbox root element now has
data-checked
attribute when the checkbox is checked - Checkbox and Radio components now support changing icon color with
iconColor
prop - use-form now supports `onVal...
7.1.7
What's Changed
[@mantine/core]
Change how primary color fallback is applied in defaulttheme.variantColorResolver
to allow setting custom fallback values andundefined
handling[@mantine/core]
Select: Fix error thrown on blur when givenvalue
is not in the data array[@mantine/core]
Fix option icon being smaller when option text has multiple lines[@mantine/core]
Spoiler: Fix unexpected empty space when hide label isnull
(#5126)[@mantine/core]
Button: Fix different border width of regular and disabled buttons[@mantine/core]
Table: Fix row background changing on hover in dark color scheme even whenhighlightOnHover
prop is not set[@mantine/carousel]
FixslideSize
prop not handling number values (#5050)[@mantine/core]
Add option to keep transitions when color scheme changes in useMantineColorScheme hook (#5092)[@mantine/core]
Improvepop-*
transitions animations (#5096)[@mantine/hooks]
use-local-storage: Fix error throwing if localStorage/sessionStorage is blocked by browser (#5091)[@mantine/dates]
Calendar: Fix incorrect focus logic when first item is disabled (#5078)
New Contributors
- @yongwee made their first contribution in #5091
- @sartak made their first contribution in #5126
- @yogabonito made their first contribution in #5107
Full Changelog: 7.1.5...7.1.6
7.1.5
What's Changed
[@mantine/core]
HoverCard: Fix dropdown not visible when Checkbox/Switch is used as target (#5072)[@mantine/code-highlight]
Fix code not updating when content changes (#5073)[@mantine/core]
Highlight: Fix incorrect highlighted parts when one of the array items includes substrings of other item (#5045)[@mantine/core]
Rating: Fix container overflow when the width of total item exceeds parent element width (#5057)[@mantine/core]
Radio: Fix checked icon clipping and not being centered with some sizes (#5064)[@mantine/core]
Fix incorrect callback arguments values types (#5067)[@mantine/core]
TagsInput: Fixrequired
prop not working correctly (#5032)
New Contributors
- @sunadoi made their first contribution in #5032
- @MarcoLotz made their first contribution in #5047
- @refansa made their first contribution in #5061
- @teh23 made their first contribution in #5064
- @hannahrfowler made their first contribution in #5057
- @wgpsutherland made their first contribution in #5045
Full Changelog: 7.1.3...7.1.5