@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:
LineChart component
New LineChart component:
BarChart component
New BarChart component:
Sparkline component
New Sparkline component:
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:
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.
autoContrast: true
autoContrast: false
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:
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:
Will be transformed to:
In .ts
/.js
files:
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:
Example of using enhanceGetInputProps
to add additional props to the input based on option passed to form.getInputProps
:
Your personal information is stored securely. (Just kidding!)
form.initialize
@mantine/form
now supports form.initialize
handler.
When called form.initialize
handler sets initialValues
and values
to the same value
and marks form as initialized. It can be used only once, next form.initialize
calls
are ignored.
form.initialize
is useful when you want to sync form values with backend API response:
Example with TanStack Query (react-query):
Note that form.initialize
will erase all values that were set before it was called.
It is usually a good idea to set readOnly
or disabled
on all form fields before
form.initialize
is called to prevent data loss. You can implement this with
enhanceGetInputProps:
valibot form resolver
@mantine/form
now supports validbot schema resolver:
Basic fields validation:
Nested fields validation
List fields validation:
ScrollArea scrollbars prop
ScrollArea now supports scrollbars
prop, which allows controlling directions at which scrollbars should be rendered.
Supported values are x
, y
and xy
. If scrollbars="y"
is set, only the vertical scrollbar will be rendered, and it will not be possible to scroll horizontally:
Title lineClamp prop
Title component now supports lineClamp
prop, which allows truncating text after a specified number of lines:
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iure doloremque quas dolorum. Quo amet earum alias consequuntur quam accusamus a quae beatae, odio, quod provident consectetur non repudiandae enim adipisci?
Primary color CSS variables
CSS variables for primary color are now available, you can use the following variables in your styles:
Help center
Help center is a new website with guides, tutorials and frequently asked questions. Currently, it has 14 questions, more FAQs will be added in the next releases.
- Is there DataGrid component that I can use with Mantine?
- MantineProvider was not found in component tree. What should I do?
- Can I use Mantine components as server components?
- Can I use Mantine with Create React App (CRA)?
- How can I lint CSS files?
- How to update Mantine dependencies?
- How can I add hover styles to an element?
- How can I get current color scheme value in JavaScript?
- Can I use private CSS variables to style components?
- How can I disable all inputs/inputs group inside form?
- How to use Dropzone with @mantine/form?
- How to call a function when Modal/Drawer closes and animation completes?
- How to prevent Modal from closing?
- What is the difference between searchable Select and Autocomplete?
Documentation updates
- form.getInputProps guide now has a separate page. It describes
form.getInputProps
,enhanceGetInputProps
and how to integrateform.getInputProps
with custom inputs. - assignRef function documentation has been added.
- clampUseMovePosition function documentation has been added.
- Additional documentation about hook arguments and types has been added to use-hotkeys.
- UseListStateHandlers type documentation has been added.
- Functions reference page has been added. Currently, it contains all functions that are exported from
@mantine/hooks
package. It is planned to document functions from other packages in next releases. - Examples on how to change the close icon have been added to Drawer and Modal components.
variantColorsResolver
demos have been added to ActionIcon, ThemeIcon and Badge components.
Other changes
- RichTextEditor no longer depends on
@tabler/icons
package. It is no longer required to install@tabler/icons
package to useRichTextEditor
component. Icons used in the editor are now a part of the@mantine/tiptap
package. This change improves bundling performance in several cases (mostly when usingRichTextEditor
in Next.js apps). - Badge component now supports
circle
prop which makes the badge round. - You can now reference theme values in
ff
style prop withmono
,text
andheading
values:<Box ff="mono" />
. - RichTextEditor now has
RichTextEditor.Undo
andRichTextEditor.Redo
controls. - A new
luminance
color function was added. It returns color luminance as a number between 0 and 1. - All components now support new
flex
style prop which allows settingflex
CSS property on the root element. - Collapse markup was reduced to single element, it can now be used in contexts that were previously not supported, for example, table rows.
stepHoldDelay
andstepHoldInterval
props have been added to NumberInput.- mantine-form-zod-resolver now supports
errorPriority
configuration which allows controlling the order of errors specified in the schema. This feature requires updatingmantine-form-zod-resolver
to version 1.1.0 or higher. - CloseButton now supports
icon
prop, which allows overriding default icon. It is useful when it is not possible to replaceCloseButton
, for example, in Drawer component. - Select component now calls
onChange
with an additional argument – option object. It containslabel
,value
and optionaldisabled
properties. - It is now possible to define CSS variables in
styles
prop of all components. - New use-in-viewport hook
- All Vite templates have been updated to Vite 5.0 and Vitest 1.0