Skip to content

Releases: mantinedev/mantine

3.1.9

13 Nov 08:46
Compare
Choose a tag to compare
  • Fix Tabs throwing an error when rendered with dynamic content (#416)
  • Fix PasswordInput color in dark color scheme (#414) and alignment (#413)

3.1.8

10 Nov 06:43
Compare
Choose a tag to compare

Fix incorrectly memoized onChange function in Pagination component

3.1.7

08 Nov 09:43
Compare
Choose a tag to compare
  • Fix misaligned PasswordInput in Firefox
  • Fix variant not applied to PaaswordInput
  • Add transparent color support to ColorPicker swatches

3.1.6

05 Nov 19:00
Compare
Choose a tag to compare
  • Fix incorrect uuids generated after hydration in some cases
  • Fix random autocomplete results appearing on inputs without static ids

3.1.5

05 Nov 17:48
Compare
Choose a tag to compare
  • Make PasswordInput compatible with password managers, tested with 1password and lasspass (#387)
  • Allow single date to be selected as range with allowSingleDateInRange prop in RangeCalendar and DateRangePicker components

3.1.4

03 Nov 16:47
Compare
Choose a tag to compare
  • Fix incorrect styles applied to NumberInput controls while component is used without normalize.css
  • Fix internal value not being updated in TimeInput and TimeRangeInput components while being in controlled mode

3.1.3

02 Nov 19:15
Compare
Choose a tag to compare

Add option to disable closing on click outside in Modal component with closeOnClickOutside={false} prop

3.1.2

01 Nov 17:40
Compare
Choose a tag to compare
  • Fix Title component rendering incorrect element when bundled with Vite (#366)
  • Add more instructions to contributing guide

3.1.1

01 Nov 11:48
Compare
Choose a tag to compare
  • Fix Modal and Drawer jumping animation when scrollbars were removed before animation finished
  • Fix incorrect up and down arrows handling in Select and MultiSelect components, which resulted in unexpected page scrolling on some devices

3.1.0

28 Oct 15:26
Compare
Choose a tag to compare

View changelog with demos on website

Breaking changes

  • MediaQuery now requires passing styles object and does not hide child element by default
  • Styles API static selectors no longer use kebab case (was .mantine-text-input-root, now .mantine-TextInput-root)

Configure emotion with MantineProvider

You can now set emotion cache options via MantineProvider:

<MantineProvider emotionOptions={{ key: "mantine", prepend: false }}>
  <App />
</MantineProvider>

With these options you can change styles insertion point (from 3.1 styles are prepended to head)
and configure stylis plugins. For example, you can use stylis-plugin-rtl to add rtl support:

import { MantineProvider } from "@mantine/core";
import rtlPlugin from "stylis-plugin-rtl";

function Demo() {
  return (
    <MantineProvider
      emotionOptions={{ key: "mantine", stylisPlugins: [rtlPlugin] }}
    >
      <App />
    </MantineProvider>
  );
}

Styles API on MantineProvider

You can now add styles to components with MantineProvider.
Styles will be added to every matching component rendered inside MantineProvider:

import { MantineProvider, Button, Badge } from "@mantine/core";

function Demo() {
  return (
    <MantineProvider
      styles={{
        Button: (theme) => ({
          // Shared button styles are applied to all buttons
          root: { height: 42, padding: "0 30px" },

          // These styles are applied only to buttons with outline variant
          outline: {
            // You can use any selectors inside (the same way as in createStyles function)
            "&:hover": {
              backgroundColor:
                theme.colorScheme === "dark"
                  ? theme.colors.dark[8]
                  : theme.colors.gray[0],
            },
          },
        }),

        // Use raw styles object if you do not need theme dependency
        Badge: {
          dot: {
            borderWidth: 2,
          },
        },
      }}
    >
      <Button variant="outline">Outline button</Button>
      <Button variant="filled">Filled button</Button>
      <Badge variant="dot">Dot badge</Badge>
    </MantineProvider>
  );
}

Inline styles with emotion

styles prop will no longer add inline styles, instead styles will be converted to emotion format.
This means that you now can subscribe to theme and use nested selectors in styles:

<Button
  styles={(theme) => ({
    outline: {
      "&:hover": {
        backgroundColor:
          theme.colorScheme === "dark"
            ? theme.colors.dark[8]
            : theme.colors.dark[0],
      },
    },

    root: {
      height: 56,
    },
  })}
>
  My custom button
</Button>

sx prop

All components now support sx prop. You can add styles to root element and subscribe to theme with it:

<Button
  sx={(theme) => ({
    borderColor: theme.colors.blue[9],
    "&:hover": {
      backgroundColor: theme.colors.blue[7],
    },
  })}
>
  Button with sx styles
</Button>

use-css hook

New use-css hook is a simpler alternative to createStyles function.
Hook returns css and cx functions. css function accepts styles object and returns class name:

import { useCss, Button } from "@mantine/core";

function Demo({ active }) {
  const { css, cx } = useCss();
  return (
    <Button
      className={cx(css({ backgroundColor: "red", opacity: 1 }), {
        [css({ opacity: 1 })]: active,
      })}
    >
      Custom button
    </Button>
  );
}

New components and hooks

New AppShell component allows you create responsive app shell with fixed or static position:

Снимок экрана 2021-10-28 в 18 25 48

With Skeleton component you can create placeholders to indicate loading state:

<Skeleton height={50} circle mb="xl" />
<Skeleton height={8} radius="xl" />
<Skeleton height={8} mt={6} radius="xl" />
<Skeleton height={8} mt={6} width="70%" radius="xl" />

New use-scroll-into-view hook lets you scroll given node into view within scrollable container or body element:

import { useScrollIntoView } from '@mantine/hooks';
import { Button, Paper } from '@mantine/core';

function Demo() {
  const { scrollIntoView, targetRef, scrollableRef } = useScrollIntoView();

  return (
    <>
      <Paper ref={scrollableRef} style={{ overflowY: 'scroll', height: 300, flex: 1 }}>
        <Paper ref={targetRef}>Scroll me into view<</Paper>
      </Paper>

      <Button onClick={() => scrollIntoView()}>Scroll to target</Button>
    </>
  );
}

Box component allows you to utilize new sx prop to style any component or element:

<Box
  sx={(theme) => ({
    backgroundColor:
      theme.colorScheme === "dark"
        ? theme.colors.dark[6]
        : theme.colors.gray[0],
    textAlign: "center",
    padding: theme.spacing.xl,
    borderRadius: theme.radius.md,
    cursor: "pointer",

    "&:hover": {
      backgroundColor:
        theme.colorScheme === "dark"
          ? theme.colors.dark[5]
          : theme.colors.gray[1],
    },
  })}
>
  Box lets you add inline styles with sx prop
</Box>

New features

  • Select and MultiSelect components now support custom scrollbars with react-custom-scrollbars package
  • Collapse component now supports dynamic children – you can now use this feature in all components that are built with Collapse
  • MediaQuery component now supports adding custom styles and subscribing to custom media queries
  • use-list-state hook now has new applyWhere handler
  • use-form hook now supports values on validation rule
  • Slider and RangeSlider components were migrated to use-move hook and now supports showing label on hover (new default behavior)
  • Add better focus management to Popover – now focus will be returned to last active element (made with use-focus-return hook)
  • AvatarsGroup - now supports total prop to explicitly override the truncated length.
  • Add onDropdownOpen and onDropdownClose handlers support to Select, MultiSelect and Autocomplete components

Bug fixes

  • Fix incorrect focus handling in Menu, DatePicker and DateRangePicker which resulted in focus not being shifted to control/input when dropdown was closed
  • Fix incorrect MultiSelect creatable filtering logic when the same item can be created multiple times
  • Fix layout jumping on Windows and Linux when overlay components with scroll lock are opened (Modal and Drawer), see use-scroll-lock documentation to learn how to offset elements with fixed position
  • Fix DatePicker dropdown not updating position when used near bottom edge of viewport
  • Fix incorrect random ids generated during server side rendering in Next.js
  • Prevent page from rendering twice in @mantine/next package