npm @mantine/core 9.9.0

47 minutes ago

View changelog with demos on mantine.dev website

Support Mantine development

You can now sponsor Mantine development with OpenCollective.
All funds are used to improve Mantine and create new features and components.

ColorWheel component

New ColorWheel component – a circular hue selector. Its value is a hue in
degrees (0–360) that can be converted to a color with the hsl() syntax. Drag the thumb around
the ring or use the keyboard to change the value. Supports custom ring colors, size, thickness
and can be used with uncontrolled forms:

import { ColorWheel } from '@mantine/core';

function Demo() {
  return <ColorWheel aria-label="Color wheel" size={180} thickness={24} thumbSize={20} saturation={100} lightness={50} withThumbIndicator={true} />;
}

CompareSlider component

New CompareSlider component – a before/after reveal slider. It stacks two
layers of content and clips the top one with a draggable divider to reveal the layer underneath.
The two sides can be any React nodes (images, videos, charts, plain markup), it supports vertical
orientation, custom handle, hover tracking and is fully keyboard accessible:

import { CompareSlider, Image } from '@mantine/core';

function Demo() {
  return (
    <CompareSlider
      aria-label="Compare images"
      w={{ base: 300, sm: 500 }}
      h={{ base: 192, sm: 320 }}
      before={<Image src="/before.png" alt="Before" h="100%" w="100%" fit="cover" />}
      after={
        <Image
          src="/after.png"
          alt="After"
          h="100%"
          w="100%"
          fit="cover"
          style={{ filter: 'grayscale(1)' }}
        />
      }
    />
  );
}

DownloadTrigger component

New DownloadTrigger component – a utility that triggers a client-side file
download. Similar to CopyButton, its children is a function that receives a
download handler and a loading state, so you can use any element as the trigger. It turns a
string, Blob, File or an async producer into an object URL and dispatches the download without a
server request:

import { Button, DownloadTrigger } from '@mantine/core';

const csv = `name,role
Alice,Engineer
Bob,Designer`;

function Demo() {
  return (
    <DownloadTrigger data={csv} fileName="report.csv" mimeType="text/csv">
      {({ download }) => <Button onClick={download}>Export CSV</Button>}
    </DownloadTrigger>
  );
}

use-countdown hook

New use-countdown hook – a headless countdown that can either count down to a
target date or from a given duration with start/stop/reset controls. It returns the remaining
time in milliseconds together with days/hours/minutes/seconds/milliseconds segments and
does not drift, as the remaining time is always computed from a stored end timestamp:

import { Button } from '@mantine/core';
import { useCountdown } from '@mantine/hooks';

function Demo() {
  const { count, running, start } = useCountdown({
    countStart: 30_000,
    interval: 1000,
  });

  const seconds = Math.ceil(count / 1000);

  return (
    <Button onClick={start} disabled={running} w={220}>
      {running ? `Resend code in ${seconds}s` : 'Resend code'}
    </Button>
  );
}

Large step keyboard stepping

NumberInput, Slider and RangeSlider now support
largeStep prop to move by a larger amount from the keyboard. Press Shift + Arrow or
PageUp/PageDown to step by largeStep (10 × step by default). NumberInput additionally
supports smallStep prop for finer stepping with Alt + Arrow:

import { NumberInput } from '@mantine/core';

function Demo() {
  return (
    <NumberInput
      label="Amount"
      description="Arrow = 1, Shift + Arrow or PageUp/PageDown = 10, Alt + Arrow = 0.5"
      defaultValue={100}
      step={1}
      largeStep={10}
      smallStep={0.5}
    />
  );
}

ScrollArea edge fade

ScrollArea now supports scrollFade prop that fades out content at the scrollable
edges to indicate that there is more content to scroll. The fade is shown at an edge only when there is
hidden content past it and disappears once that edge is reached. Use scrollFadeSize prop to change the
length of the fade gradient:

import { ScrollArea } from '@mantine/core';

function Demo() {
  return (
    <ScrollArea h={250} w={400} scrollFade>
      {/* ... content */}
    </ScrollArea>
  );
}

QRCode component

New QRCode component generates and renders QR codes as SVG. The
encoder is bundled with @mantine/core, so it works without additional dependencies
and supports server-side rendering. It is themeable with the color and bg props,
supports a centered logo overlay, and exposes the encodeQR function for custom
rendering:

import { QRCode } from '@mantine/core';

function Demo() {
  return <QRCode value="https://mantine.dev" />;
}

Tilt component

New Tilt component rotates its content in 3D in response to the pointer position
and device orientation. It owns the perspective container and the transform, supports a layered
depth effect with Tilt.Layer, an optional pointer-following withGlare, trackWindow to react
to the pointer anywhere on the page, and respects prefers-reduced-motion:

import { Box, Text, Tilt, Title } from '@mantine/core';

function Demo() {
  return (
    <Tilt maxRotate={14} radius="lg">
      <Box
        style={{
          position: 'relative',
          overflow: 'hidden',
          width: 320,
          height: 220,
          borderRadius: 'var(--mantine-radius-lg)',
          backgroundImage: 'linear-gradient(160deg, #1b1f3b 0%, #3b2f63 60%, #7b3fa0 100%)',
        }}
      >
        {/* Background layer moves the least */}
        <Tilt.Layer depth={0.25} shift={16} style={{ position: 'absolute', inset: 0 }}>
          <Box
            style={{
              position: 'absolute',
              top: 120,
              left: '50%',
              width: 220,
              height: 220,
              transform: 'translateX(-50%)',
              borderRadius: '50%',
              backgroundImage: 'radial-gradient(circle at 40% 35%, #ffd43b, #f76707)',
            }}
          />
        </Tilt.Layer>

        {/* Foreground text pops out the most */}
        <Tilt.Layer
          depth={1.4}
          style={{
            position: 'absolute',
            inset: 0,
            display: 'flex',
            flexDirection: 'column',
            alignItems: 'center',
            justifyContent: 'center',
          }}
        >
          <Title order={2} c="white">
            PARALLAX
          </Title>
          <Text c="rgba(255, 255, 255, 0.7)">depth in motion</Text>
        </Tilt.Layer>
      </Box>
    </Tilt>
  );
}

use-tilt hook

New use-tilt hook powers the Tilt component. It produces normalized roll
and tilt values from the pointer position over a target element and, when available, the device
orientation gyroscope. It is headless – map the returned values to CSS transforms to build tilt
and layered depth effects that respond to the cursor on desktop and to device tilt on mobile:

import { Box, Group, Stack, Text } from '@mantine/core';
import { useTilt } from '@mantine/hooks';

function Demo() {
  const { ref, roll, tilt } = useTilt<HTMLDivElement>();

  // Animate 2x slower when the card returns to its neutral position
  const isNeutral = roll === 0 && tilt === 0;
  const transition = `transform ${isNeutral ? 300 : 150}ms ease-out`;

  return (
    <Box ref={ref} style={{ perspective: 1000, display: 'inline-block' }}>
      <Box
        style={{
          position: 'relative',
          overflow: 'hidden',
          width: 340,
          height: 214,
          padding: 'var(--mantine-spacing-xl)',
          borderRadius: 'var(--mantine-radius-lg)',
          color: 'var(--mantine-color-white)',
          backgroundImage: 'linear-gradient(135deg, #4263eb 0%, #7048e8 55%, #ae3ec9 100%)',
          boxShadow: 'var(--mantine-shadow-xl)',
          transform: `rotateX(${roll * 18}deg) rotateY(${tilt * 18}deg)`,
          transition,
        }}
      >
        <Box
          style={{
            position: 'absolute',
            inset: 0,
            pointerEvents: 'none',
            background:
              'radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%)',
            transform: `translate(${tilt * 55}%, ${-roll * 55}%)`,
            transition,
          }}
        />

        <Stack justify="space-between" h="100%" gap={0} style={{ position: 'relative' }}>
          <Group justify="space-between" align="flex-start">
            <Box
              style={{
                width: 44,
                height: 32,
                borderRadius: 6,
                backgroundImage: 'linear-gradient(135deg, #ffd43b, #f59f00)',
              }}
            />
            <Text fw={700} fz="lg" fs="italic">
              VISA
            </Text>
          </Group>

          <Text fz="md" ff="monospace" style={{ letterSpacing: 1, whiteSpace: 'nowrap' }}>
            4242 4242 4242 4242
          </Text>

          <Group justify="space-between">
            <Stack gap={2}>
              <Text fz={10} opacity={0.7} tt="uppercase">Card holder</Text>
              <Text fw={500}>Jane Cooper</Text>
            </Stack>
            <Stack gap={2}>
              <Text fz={10} opacity={0.7} tt="uppercase">Expires</Text>
              <Text fw={500}>08 / 28</Text>
            </Stack>
          </Group>
        </Stack>
      </Box>
    </Box>
  );
}

Persona component

New Persona component displays a person identity: an avatar, an optional
presence badge and up to four stacked text lines. It composes Avatar and renders its own
presence badge in a single component that is useful in people pickers, contact and chat lists,
comment authors and profile headers. It supports presence statuses, initials and
image avatars, configurable text position and alignment, and a polymorphic root:

import { Paper, Persona, PersonaPresenceValue, Stack } from '@mantine/core';

const members: { name: string; role: string; image: string; presence: PersonaPresenceValue }[] = [
  { name: 'Emily Johnson', role: 'Product manager', image: image1, presence: 'available' },
  { name: 'Kevin Gilbert', role: 'Frontend developer', image: image2, presence: 'do-not-disturb' },
  { name: 'Mary Smith', role: 'UX researcher', image: image3, presence: { status: 'busy', outOfOffice: true } },
  { name: 'Robert Wolf', role: 'Backend developer', image: image4, presence: 'offline' },
];

function Demo() {
  return (
    <Paper withBorder p="md" radius="md">
      <Stack gap="lg">
        {members.map((person) => (
          <Persona
            key={person.name}
            name={person.name}
            secondaryText={person.role}
            avatar={{ src: person.image }}
            presence={person.presence}
          />
        ))}
      </Stack>
    </Paper>
  );
}

Stat component

New Stat component displays a single key metric: a label, a formatted value,
an optional prefix/suffix, a trend indicator and a countdown variant. It composes existing
NumberFormatter, RollingNumber and Skeleton primitives into the dashboard-stat primitive,
with a diff prop for up/down trends, an animate prop for value transitions, a loading state
and a Stat.Countdown sub-component that ticks down to a target time:

import { CoinsIcon, ShoppingCartIcon, UsersIcon } from '@phosphor-icons/react';
import { Paper, SimpleGrid, Stat } from '@mantine/core';

function Demo() {
  return (
    <SimpleGrid cols={{ base: 1, sm: 3 }} w="100%">
      <Paper withBorder p="md" radius="md">
        <Stat label="Active users" value={92410} thousandSeparator diff={12.4} icon={<UsersIcon size={26} />} />
      </Paper>
      <Paper withBorder p="md" radius="md">
        <Stat label="Revenue" value={1340.5} prefix="$" decimalScale={2} fixedDecimalScale thousandSeparator diff={-4.1} icon={<CoinsIcon size={26} />} />
      </Paper>
      <Paper withBorder p="md" radius="md">
        <Stat label="Orders" value={2847} thousandSeparator diff={0.8} icon={<ShoppingCartIcon size={26} />} />
      </Paper>
    </SimpleGrid>
  );
}

ResourcesWeekView day cells

ResourcesWeekView now supports layout="days" to display a compact week with stacked events in day cells.
Use it to see many resources at once without a time axis:

// Demo.tsx
import { useState } from 'react';
import { ResourcesWeekView } from '@mantine/schedule';
import { events, groups, resources } from './data';

function Demo() {
  const [date, setDate] = useState('2026-10-28');
  const [data, setData] = useState(events);

  return (
    <ResourcesWeekView
      layout="days"
      date={date}
      onDateChange={setDate}
      resources={resources}
      groups={groups}
      events={data}
      dayWidth={80}
      rowHeight={80}
      withEventsDragAndDrop
      withEventResize
      onEventDrop={({ eventId, newStart, newEnd, resourceId }) =>
        setData((current) =>
          current.map((event) =>
            event.id === eventId ? { ...event, start: newStart, end: newEnd, resourceId } : event
          )
        )
      }
      onEventResize={({ eventId, newStart, newEnd }) =>
        setData((current) =>
          current.map((event) =>
            event.id === eventId ? { ...event, start: newStart, end: newEnd } : event
          )
        )
      }
    />
  );
}

// data.ts
import { ScheduleEventData, ScheduleResourceData, ScheduleResourceGroup } from '@mantine/schedule';

export const resources: ScheduleResourceData[] = ${JSON.stringify(resources, null, 2)};

export const groups: ScheduleResourceGroup[] = ${JSON.stringify(groups, null, 2)};

export const events: ScheduleEventData[] = ${JSON.stringify(events, null, 2)};

PhoneInput extensions

PhoneInput now supports phone extensions, for example, +12025551234x1234.
Set withExtension to let users enter an extension after x:

import { useState } from 'react';
import { Code, PhoneInput } from '@mantine/core';

function Demo() {
  const [value, setValue] = useState('+12025551234x1234');

  return (
    <>
      <PhoneInput
        label="Office phone"
        description="Enter an extension after x"
        withExtension
        value={value}
        onChange={setValue}
      />
      <Code block mt="md">{value}</Code>
    </>
  );
}

Don't miss a new core release

NewReleases is sending notifications on new releases.