# Version v10.0.0

## Support Mantine development

You can now sponsor Mantine development with [OpenCollective](https://opencollective.com/mantinedev).
All funds are used to improve Mantine and create new features and components.

## Migration guide

This changelog covers breaking changes and new features in Mantine 10.0.
To migrate your application to Mantine 10.0, follow [9.x → 10.x migration guide](https://alpha.mantine.dev/llms/guides-9x-to-10x.md).

## @mantine/data-grid package

New [@mantine/data-grid](https://alpha.mantine.dev/llms/data-grid-getting-started.md) package provides a data grid built on
TanStack Table with sorting, filtering, pagination, editing, virtualization and server-side data:

```tsx
// Demo.tsx
import { useState } from 'react';
import { Badge, Button, Group, NumberFormatter, NumberInput, Popover, Select, Stack } from '@mantine/core';
import { DataGrid, DataGridStore, useDataGrid } from '@mantine/data-grid';
import { orders, statusColors } from './data';
import type { Order } from './data';

function FiltersPopover({ store }: { store: DataGridStore<Order> }) {
  const [opened, setOpened] = useState(false);
  const activeCount = store.getColumnFilters().length;
  const amount = (store.getColumnFilterValue('amount') as [number?, number?] | undefined) ?? [];

  const setAmount = (index: 0 | 1, value: string | number) => {
    const next: [number?, number?] = [amount[0], amount[1]];
    next[index] = typeof value === 'number' ? value : undefined;
    store.setColumnFilter('amount', next[0] == null && next[1] == null ? undefined : next);
  };

  return (
    <Popover opened={opened} onChange={setOpened} position="bottom-start" shadow="md">
      <Popover.Target>
        <Button
          variant="default"
          size={store.getControlSize()}
          onClick={() => setOpened((o) => !o)}
          rightSection={
            activeCount > 0 ? (
              <Badge size="xs" circle>
                {activeCount}
              </Badge>
            ) : null
          }
        >
          Filters
        </Button>
      </Popover.Target>
      <Popover.Dropdown>
        <Stack gap="sm" w={260}>
          <Select
            label="Status"
            placeholder="All statuses"
            clearable
            size="xs"
            data={store.getFacetedUniqueValues('status')}
            value={(store.getColumnFilterValue('status') as string) ?? null}
            onChange={(value) => store.setColumnFilter('status', value)}
          />
          <Select
            label="Payment"
            placeholder="All methods"
            clearable
            size="xs"
            data={store.getFacetedUniqueValues('method')}
            value={(store.getColumnFilterValue('method') as string) ?? null}
            onChange={(value) => store.setColumnFilter('method', value)}
          />
          <Group grow gap="xs">
            <NumberInput
              label="Min amount"
              placeholder="Min"
              size="xs"
              prefix="$"
              value={amount[0] ?? ''}
              onChange={(value) => setAmount(0, value)}
            />
            <NumberInput
              label="Max amount"
              placeholder="Max"
              size="xs"
              prefix="$"
              value={amount[1] ?? ''}
              onChange={(value) => setAmount(1, value)}
            />
          </Group>
          <Group justify="flex-end">
            <Button
              size="xs"
              variant="default"
              disabled={activeCount === 0}
              onClick={() => store.resetColumnFilters()}
            >
              Clear all
            </Button>
          </Group>
        </Stack>
      </Popover.Dropdown>
    </Popover>
  );
}

function Demo() {
  const store = useDataGrid({
    data: orders,
    columns: [
      { accessorKey: 'id', header: 'Order', size: 110, enableSorting: true },
      { accessorKey: 'customer', header: 'Customer', size: 160, enableSorting: true },
      { accessorKey: 'product', header: 'Product', size: 180, enableSorting: true },
      {
        accessorKey: 'amount',
        header: 'Amount',
        size: 120,
        enableSorting: true,
        filterFn: 'inNumberRange',
        meta: { align: 'end' },
        cell: ({ getValue }) => (
          <NumberFormatter
            value={getValue() as number}
            prefix="$"
            thousandSeparator
            decimalScale={2}
          />
        ),
      },
      {
        accessorKey: 'status',
        header: 'Status',
        size: 130,
        enableSorting: true,
        filterFn: 'equals',
        cell: ({ getValue }) => {
          const status = getValue() as Order['status'];
          return (
            <Badge variant="filled" color={statusColors[status]} size="sm">
              {status}
            </Badge>
          );
        },
      },
      {
        accessorKey: 'date',
        header: 'Date',
        size: 120,
        enableSorting: true,
        cell: ({ getValue }) =>
          new Date(getValue() as string).toLocaleDateString('en-US', {
            month: 'short',
            day: 'numeric',
            year: 'numeric',
          }),
      },
      { accessorKey: 'method', header: 'Payment', size: 130, filterFn: 'equals' },
    ],
    getRowId: (row) => row.id,
    withGlobalFilter: true,
    withRowSelection: true,
    withColumnVisibility: true,
    withFaceting: true,
    pageSize: 20,
  });

  return (
    <DataGrid store={store} highlightOnHover>
      <DataGrid.Toolbar>
        <DataGrid.GlobalFilter placeholder="Search orders..." />
        <FiltersPopover store={store} />
        <div style={{ flex: 1 }} />
        <DataGrid.ColumnVisibilityToggle />
        <DataGrid.ExportButton fileName="orders" />
      </DataGrid.Toolbar>
      <DataGrid.SelectionBar>
        <Button size={store.getControlSize()} variant="default">
          Mark as shipped
        </Button>
        <Button size={store.getControlSize()} variant="default">
          Cancel orders
        </Button>
      </DataGrid.SelectionBar>
      <DataGrid.Footer statusFormat="long" />
    </DataGrid>
  );
}

// data.ts
export interface Order {
  id: string;
  customer: string;
  product: string;
  amount: number;
  status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
  date: string;
  method: string;
}

export const statusColors: Record<Order['status'], string> = {
  pending: 'yellow',
  processing: 'blue',
  shipped: 'indigo',
  delivered: 'green',
  cancelled: 'red',
};

export const orders: Order[] = ${JSON.stringify(orders.slice(0, 10), null, 2)};
```


## ImageCropper component

New [ImageCropper](https://alpha.mantine.dev/llms/core-image-cropper.md) lets users pan, zoom, rotate and flip an image inside a rectangular or circular crop window.
Export the crop as a `Blob` or data URL, or use its coordinates to crop the image on the server:

```tsx
import { ImageCropper } from '@mantine/core';

const image = 'https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/images/bg-9.png';

function Demo() {
  return (
    <ImageCropper
      src={image}
      crossOrigin="anonymous"
      maw={360}
      mx="auto"
      withControls
    />
  );
}
```


## Timer component

New [Timer](https://alpha.mantine.dev/llms/core-timer.md) displays a countdown or stopwatch with controls to pause, resume and restart it.
Use `useTimer` on its own or build a custom layout with `Timer`:

```tsx
import { ActionIcon, Group, Timer } from '@mantine/core';
import { ArrowCounterClockwiseIcon, PauseIcon, PlayIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <Timer countdown startMs={5 * 60 * 1000} autoStart>
      <Group gap={4} fz={36} fw={700}>
        <Timer.Segment type="minutes" />
        <Timer.Separator>:</Timer.Separator>
        <Timer.Segment type="seconds" />
      </Group>

      <Group gap="xs">
        <Timer.Control action="start" aria-label="Start">
          <ActionIcon component="span" variant="light">
            <PlayIcon size={18} weight="fill" />
          </ActionIcon>
        </Timer.Control>
        <Timer.Control action="pause" aria-label="Pause">
          <ActionIcon component="span" variant="light">
            <PauseIcon size={18} weight="fill" />
          </ActionIcon>
        </Timer.Control>
        <Timer.Control action="restart" aria-label="Restart">
          <ActionIcon component="span" variant="light">
            <ArrowCounterClockwiseIcon size={18} />
          </ActionIcon>
        </Timer.Control>
      </Group>
    </Timer>
  );
}
```


## Editable component

New [Editable](https://alpha.mantine.dev/llms/core-editable.md) lets users edit text in place. Press `Enter` to save or `Escape` to cancel, or add buttons for both actions:

```tsx
import { ActionIcon, Editable, Group } from '@mantine/core';
import { CheckIcon, PencilSimpleIcon, XIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <Editable defaultValue="Project name" activationMode="none">
      <Group gap="xs">
        <Editable.Preview />
        <Editable.Input />
        <Editable.Control>
          <Editable.EditTrigger aria-label="Edit">
            <ActionIcon component="span" variant="default">
              <PencilSimpleIcon size={16} />
            </ActionIcon>
          </Editable.EditTrigger>
          <Editable.SubmitTrigger aria-label="Save">
            <ActionIcon component="span" variant="default">
              <CheckIcon size={16} />
            </ActionIcon>
          </Editable.SubmitTrigger>
          <Editable.CancelTrigger aria-label="Cancel">
            <ActionIcon component="span" variant="default">
              <XIcon size={16} />
            </ActionIcon>
          </Editable.CancelTrigger>
        </Editable.Control>
      </Group>
    </Editable>
  );
}
```


## FileSize component

New [FileSize](https://alpha.mantine.dev/llms/core-file-size.md) displays a byte count in a readable format, such as `1.45 kB`.
Use `formatBytes` to get the same localized value as a string:

```tsx
import { FileSize, Table } from '@mantine/core';

const files = [
  { name: 'avatar.png', size: 15360 },
  { name: 'report.pdf', size: 1_450_000 },
  { name: 'backup.zip', size: 4_800_000_000 },
];

function Demo() {
  return (
    <Table>
      <Table.Thead>
        <Table.Tr>
          <Table.Th>File</Table.Th>
          <Table.Th>Size</Table.Th>
        </Table.Tr>
      </Table.Thead>
      <Table.Tbody>
        {files.map((file) => (
          <Table.Tr key={file.name}>
            <Table.Td>{file.name}</Table.Td>
            <Table.Td>
              <FileSize value={file.size} />
            </Table.Td>
          </Table.Tr>
        ))}
      </Table.Tbody>
    </Table>
  );
}
```


## CodeHighlightFileTree component

New [CodeHighlightFileTree](https://alpha.mantine.dev/llms/code-highlight-code-highlight.md#file-tree) component displays
multi-file code with a file tree instead of tabs. `/` in `fileName` creates folders, the active
file can be controlled with `activeFile` and `onActiveFileChange` props, and below `hideTreeBelow`
breakpoint the tree is replaced with a select:

```tsx
// Demo.tsx
import { CodeHighlightFileTree } from '@mantine/code-highlight';
import { fileTreeCode } from './data';
import { getFileIcon, getFolderIcon } from './icons';

function Demo() {
  return (
    <CodeHighlightFileTree
      code={fileTreeCode}
      getFileIcon={getFileIcon}
      getFolderIcon={getFolderIcon}
      radius="md"
      withBorder
    />
  );
}

// icons.tsx
import {
  BracketsCurlyIcon,
  FileSvgIcon,
  FileTextIcon,
  FolderOpenIcon,
  FolderSimpleIcon,
} from '@phosphor-icons/react';
import { CssIcon, TypeScriptIcon } from '@mantinex/dev-icons';

export function getFileIcon(fileName: string) {
  if (fileName.endsWith('.ts') || fileName.endsWith('.tsx')) {
    return <TypeScriptIcon size={14} />;
  }

  if (fileName.endsWith('.css')) {
    return <CssIcon size={14} />;
  }

  if (fileName.endsWith('.json')) {
    return <BracketsCurlyIcon size={14} />;
  }

  if (fileName.endsWith('.svg')) {
    return <FileSvgIcon size={14} />;
  }

  return <FileTextIcon size={14} />;
}

export function getFolderIcon(_folderPath: string, expanded: boolean) {
  return expanded ? <FolderOpenIcon size={14} /> : <FolderSimpleIcon size={14} />;
}

// data.ts
export const fileTreeCode = [
  { fileName: 'JobApplicationForm.tsx', language: 'tsx', code: '...' },
  { fileName: 'JobApplicationForm.module.css', language: 'scss', code: '...' },
  { fileName: 'steps/PersonalStep.tsx', language: 'tsx', code: '...' },
  { fileName: 'steps/PersonalStep.module.css', language: 'scss', code: '...' },
  { fileName: 'steps/address/AddressStep.tsx', language: 'tsx', code: '...' },
  { fileName: 'steps/address/countries.json', language: 'json', code: '...' },
  { fileName: 'assets/logo.svg', language: 'html', code: '...' },
  { fileName: 'types.ts', language: 'tsx', code: '...' },
  { fileName: 'validation.ts', language: 'tsx', code: '...' },
  { fileName: 'README.md', language: 'text', code: '...' },
  { fileName: 'JobApplicationForm.test.tsx', language: 'tsx', code: '...' },
];
```


## Component controllers and stores

Use a [controller](https://alpha.mantine.dev/llms/guides-controllers.md) to trigger component actions from your own controls. For example, `useAccordion` lets a button expand all items:

```tsx
// Demo.tsx
import { Accordion, Button, Group, Text, useAccordion } from '@mantine/core';
import { data } from './data';

function Demo() {
  const controller = useAccordion({ multiple: true });

  const items = data.map((item) => (
    <Accordion.Item key={item.value} value={item.value}>
      <Accordion.Control icon={item.emoji}>{item.value}</Accordion.Control>
      <Accordion.Panel>{item.description}</Accordion.Panel>
    </Accordion.Item>
  ));

  return (
    <>
      <Group justify="center" mb="md">
        <Button onClick={controller.expandAll}>Expand all</Button>
        <Button variant="default" onClick={controller.collapseAll}>
          Collapse all
        </Button>
        <Button variant="default" onClick={() => controller.toggle('Bananas')}>
          Toggle bananas
        </Button>
      </Group>

      <Accordion controller={controller} order={3}>
        {items}
      </Accordion>

      <Text ta="center" mt="md" size="sm" c="dimmed">
        Expanded: {controller.getExpandedItems().join(', ') || 'none'}
      </Text>
    </>
  );
}

// data.ts
export const data = [
  {
    emoji: '🍎',
    value: 'Apples',
    description:
      'Crisp and refreshing fruit. Apples are known for their versatility and nutritional benefits. They come in a variety of flavors and are great for snacking, baking, or adding to salads.',
  },
  {
    emoji: '🍌',
    value: 'Bananas',
    description:
      'Naturally sweet and potassium-rich fruit. Bananas are a popular choice for their energy-boosting properties and can be enjoyed as a quick snack, added to smoothies, or used in baking.',
  },
  {
    emoji: '🥦',
    value: 'Broccoli',
    description:
      'Nutrient-packed green vegetable. Broccoli is packed with vitamins, minerals, and fiber. It has a distinct flavor and can be enjoyed steamed, roasted, or added to stir-fries.',
  },
];
```


Use a store to build on an existing component. For example, [useSelect](https://alpha.mantine.dev/llms/core-select.md#building-on-select-with-useselect) lets you build a select that creates new options:

```tsx
import { useState } from 'react';
import { Select, SelectProps, useSelect } from '@mantine/core';

interface CreatableSelectProps extends Omit<SelectProps, 'data' | 'store' | 'renderOption'> {
  data: string[];
  onCreate: (item: string) => void;
}

function CreatableSelect({ data, onCreate, value, defaultValue, onChange, ...others }: CreatableSelectProps) {
  const store = useSelect({
    value,
    defaultValue,
    onChange: (item, option) => {
      if (item !== null && !data.includes(item)) {
        onCreate(item);
      }

      onChange?.(item, option);
    },
  });

  const search = store.getSearch().trim();
  const canCreate = search !== '' && !data.includes(search);

  return (
    <Select
      {...others}
      store={store}
      searchable
      data={canCreate ? [...data, search] : data}
      renderOption={({ option }) =>
        data.includes(option.value) ? option.label : `+ Create ${option.label}`
      }
    />
  );
}

function Demo() {
  const [data, setData] = useState(['Apples', 'Bananas', 'Broccoli', 'Carrots', 'Chocolate']);

  return (
    <CreatableSelect
      label="Your favorite grocery"
      placeholder="Search or create"
      data={data}
      onCreate={(item) => setData((current) => [...current, item])}
    />
  );
}
```


## Theme editor

New [theme editor](https://themes.mantine.dev) lets you build a theme from ready-made presets and preview it on real pages.
Adjust colors, fonts, spacing and shadows, then copy the theme code or a prompt for your coding agent.

## OKLCH default palettes

Default colors are regenerated in the OKLCH color space: shades with the same index now look
equally bright in every color. Existing color names and the number of shades are unchanged,
see the [migration guide](https://alpha.mantine.dev/llms/guides-9x-to-10x.md) if you parse `--mantine-color-*` variables.

## Colors generator

`generateColors` from `@mantine/colors-generator` now returns OKLCH colors and keeps the input color
in the palette. The second argument adjusts lightness, saturation and hue of the generated shades,
see [colors generation](https://alpha.mantine.dev/llms/theming-colors.md#colors-generation). The online tool moved to
[themes.mantine.dev/colors-generator](https://themes.mantine.dev/colors-generator/), it has presets and a
separate palette for dark color scheme:

```tsx
import { createTheme } from '@mantine/core';
import { generateColors } from '@mantine/colors-generator';

const theme = createTheme({
  colors: {
    brand: generateColors('#375EAC', { baseShade: 7, hueShift: 10 }),
  },
});
```

## Neutral color

New [neutral color](https://alpha.mantine.dev/llms/theming-colors.md#neutral-color) is black in light mode and white in dark mode.
Use `color="neutral"` on individual components or set `primaryColor: 'neutral'` in your theme:

```tsx
import { Button, Group } from '@mantine/core';

function Demo() {
  return (
    <Group>
      <Button color="neutral" variant="filled">Filled</Button>
      <Button color="neutral" variant="light">Light</Button>
      <Button color="neutral" variant="outline">Outline</Button>
      <Button color="neutral" variant="subtle">Subtle</Button>
      <Button color="neutral" variant="transparent">Transparent</Button>
      <Button color="neutral" variant="white">White</Button>
    </Group>
  );
}
```


## Neutral color ladder

New `--mantine-color-neutral-0` to `--mantine-color-neutral-9` variables adapt to the color scheme.
Use them in custom CSS instead of separate gray and dark shades:

```css
.card {
  background-color: var(--mantine-color-neutral-1);
  border: 1px solid var(--mantine-color-border);
}
```

## Dark neutral flavors

New `darkColdColors`, `darkWarmColors` and `darkTintedColors` palettes change the tone of the dark
color scheme. Assign one of them to `theme.colors.dark`:

```tsx
import { createTheme, darkWarmColors } from '@mantine/core';

const theme = createTheme({
  colors: {
    dark: darkWarmColors,
  },
});
```

## Neutral shades tint

New `grayWarmColors` and `grayColdColors` palettes provide warm and cold neutrals for the light color scheme.
Use `mixNeutralColors` from `@mantine/colors-generator` to blend your primary color into [neutral shades](https://alpha.mantine.dev/llms/theming-colors.md#neutral-shades-tint):

```tsx
import { mixNeutralColors } from '@mantine/colors-generator';
import {
  createTheme,
  darkWarmColors,
  DEFAULT_THEME,
  grayWarmColors,
} from '@mantine/core';

const tint = DEFAULT_THEME.colors.blue[6];

const theme = createTheme({
  colors: {
    dark: mixNeutralColors(darkWarmColors, tint, 8),
    gray: mixNeutralColors(grayWarmColors, tint, 3.2),
  },
});
```

## tintColors utility

New `tintColors` function mixes a color into every shade of the dark palette:

```tsx
import { createTheme, darkColors, tintColors } from '@mantine/core';

const theme = createTheme({
  colors: {
    dark: tintColors(darkColors, '#5c7cfa', 0.15),
  },
});
```

## Semantic color CSS variables

Override [semantic color variables](https://alpha.mantine.dev/llms/theming-colors.md#semantic-color-variables) to restyle components together. For example, change every focus ring in dark mode:

```css
[data-mantine-color-scheme='dark'] {
  --mantine-color-focus-ring: var(--mantine-color-lime-4);
}
```

## Surface component

New [Surface](https://alpha.mantine.dev/llms/core-surface.md) component replaces `Paper`, which is deprecated and will be removed in 11.0.
Nested surfaces step up one level automatically, so elevation is visible in dark mode:

```tsx
import { Surface } from '@mantine/core';

function Demo() {
  return (
    <Surface p="md" withBorder>
      Outer surface
      <Surface p="md">Inner surface, one level higher</Surface>
    </Surface>
  );
}
```

Use the `surfaces` theme key to change surface colors for each color scheme:

```tsx
import { createTheme } from '@mantine/core';

const theme = createTheme({
  surfaces: {
    dark: {
      panel: '#101113',
    },
  },
});
```

## Inputs share one surface token

Inputs, checkboxes, radios, `Dropzone` and `RichTextEditor` now share the `--mantine-color-surface-input`
variable, which is white in light mode and `dark-7` in dark mode. The editor matches the other inputs,
and one override restyles all of them. Change it with the `surfaces` theme key:

```tsx
import { createTheme } from '@mantine/core';

const theme = createTheme({
  surfaces: {
    dark: {
      input: 'var(--mantine-color-dark-8)',
    },
  },
});
```

## Dropdowns render on the page surface

Dropdowns of `Popover`, `Menu` and `Combobox` based components now use the page background, like `Modal`.
In dark mode they are darker than before and are separated from the content with a border and a shadow.

## Sunken surfaces, code surfaces and control tracks

Segmented controls, contained tabs and scrollbars now share one sunken surface color.
Code elements share one muted surface color, and tracks of switches, sliders and progress bars
use the new `--mantine-color-track` variable.

## autoContrast enabled by default

Filled components now pick black or white text to match their background color.
Set `autoContrast: false` in the theme to restore the previous behavior.

## Disabled state opacity

Disabled components now look like a faded version of their normal state instead of turning gray.
Change the opacity with `theme.disabledOpacity`:

```tsx
import { MantineProvider, Button, Checkbox, Switch, TextInput } from '@mantine/core';

function Demo() {
  return (
    <MantineProvider theme={{ disabledOpacity: 0.5 }}>
      <Button disabled>Disabled button</Button>
      <TextInput mt="md" label="Disabled input" placeholder="Disabled input" disabled />
      <Checkbox mt="md" label="Disabled checkbox" defaultChecked disabled />
      <Switch mt="md" label="Disabled switch" defaultChecked disabled />
    </MantineProvider>
  );
}
```


## use-form engine and uncontrolled mode

`useForm` is now uncontrolled by default. Typing rerenders only the input, not the whole form,
and `form.key()` is no longer needed:

```tsx
import { TextInput } from '@mantine/core';
import { useForm } from '@mantine/form';

function Demo() {
  const form = useForm({ initialValues: { email: '' } });
  return <TextInput label="Email" {...form.getInputProps('email')} />;
}
```

New `form.useDirty` and `form.useTouched` hooks subscribe a component to dirty and touched state,
and custom inputs subscribe to a field with the `useFormField` hook.
See [uncontrolled mode](https://alpha.mantine.dev/llms/form-uncontrolled.md) for details.

## Reusable form fields

New `form.getField('path')` returns a field object with the same type as `useField`.
A component that accepts it works with any form, see [reusable fields](https://alpha.mantine.dev/llms/form-reusable-fields.md):

```tsx
import { TextInput } from '@mantine/core';
import { useField, useForm, UseFieldReturnType } from '@mantine/form';

function EmailField({ field }: { field: UseFieldReturnType<string> }) {
  return <TextInput label="Email" {...field.getInputProps()} />;
}

function Demo() {
  const signup = useForm({ initialValues: { email: '' } });
  const checkout = useForm({ initialValues: { contact: { email: '' } } });
  const newsletter = useField({ initialValue: '' });

  return (
    <>
      <EmailField field={signup.getField('email')} />
      <EmailField field={checkout.getField('contact.email')} />
      <EmailField field={newsletter} />
    </>
  );
}
```

## Conditional validation

New `when` validator runs a rule only when the condition returns `true`.
Use it for fields that are required depending on another field, see [validators](https://alpha.mantine.dev/llms/form-validators.md#when):

```tsx
import { isNotEmpty, useForm, when } from '@mantine/form';

const form = useForm({
  initialValues: { isCompany: false, companyName: '' },
  validate: {
    companyName: when(
      (values) => values.isCompany,
      isNotEmpty('Company name is required')
    ),
  },
});
```

## Focus form inputs

`form.focusInput(path)` focuses an input or a control inside a group, such as `Radio.Group`.
Use it to focus the first invalid field on submit, see [form submission](https://alpha.mantine.dev/llms/form-submission.md):

```tsx
import { Button, Group, Radio, TextInput } from '@mantine/core';
import { isEmail, isNotEmpty, useForm } from '@mantine/form';

function Demo() {
  const form = useForm({
    name: 'register-form',
    initialValues: {
      name: '',
      email: '',
      contact: '',
    },

    validate: {
      name: isNotEmpty('Name is required'),
      email: isEmail('Invalid email'),
      contact: isNotEmpty('Choose how to contact you'),
    },
  });

  return (
    <form
      onSubmit={form.onSubmit(
        (values) => console.log(values),
        (errors) => {
          const firstErrorPath = Object.keys(errors)[0];
          form.focusInput(firstErrorPath);
        }
      )}
    >
      <TextInput
        withAsterisk
        label="Your name"
        placeholder="Your name"
        {...form.getInputProps('name')}
      />

      <TextInput
        withAsterisk
        label="Your email"
        placeholder="your@email.com"
        mt="md"
        {...form.getInputProps('email')}
      />

      <Radio.Group label="Preferred contact" withAsterisk mt="md" {...form.getInputProps('contact')}>
        <Radio label="Email" value="email" />
        <Radio label="Phone" value="phone" />
      </Radio.Group>

      <Group justify="flex-end" mt="md">
        <Button type="submit">Submit</Button>
      </Group>
    </form>
  );
}
```


## Virtualized combobox dropdowns

Pass a `virtualizer` component to render large dropdowns with the scrolling library of your choice.
It works with the following components:

* [Autocomplete](https://alpha.mantine.dev/llms/core-autocomplete.md#virtualized-dropdown), [Select](https://alpha.mantine.dev/llms/core-select.md#virtualized-dropdown), [MultiSelect](https://alpha.mantine.dev/llms/core-multi-select.md#virtualized-dropdown), and [TagsInput](https://alpha.mantine.dev/llms/core-tags-input.md#virtualized-dropdown)
* [ComboboxPopover](https://alpha.mantine.dev/llms/core-combobox-popover.md#virtualized-dropdown), [TreeSelect](https://alpha.mantine.dev/llms/core-tree-select.md#virtualized-dropdown), and the [PhoneInput country picker](https://alpha.mantine.dev/llms/core-phone-input.md#virtualized-dropdown)
* [Mentions overlay suggestions](https://alpha.mantine.dev/llms/core-mentions.md#virtualized-dropdown) and [Cascader flat lists](https://alpha.mantine.dev/llms/core-cascader.md#virtualized-dropdown)

This Autocomplete lets you search and navigate 10,000 options while rendering only the visible rows:

```tsx
import { Autocomplete } from '@mantine/core';
import { VirtualList } from './VirtualList';

${dataCode}

function Demo() {
  return (
    <Autocomplete
      label="Search 10,000 options"
      placeholder="Type an option number"
      data={data}
      virtualizer={VirtualList}
    />
  );
}
```


## Mobile-friendly dates dropdowns

Date picker inputs and `DateTimePicker` now open in a bottom drawer on small screens.
Use `dropdownType` prop to choose the dropdown type for each breakpoint:



In drawer and modal dropdowns, the value is applied when the user presses the submit button.
Set `applyOnSubmit={false}` to apply it on selection:



[DateTimePicker](https://alpha.mantine.dev/llms/dates-date-time-picker.md#mobile-time-input) uses the native time input in the drawer:

```tsx
import { Stack } from '@mantine/core';
import { DateTimePicker } from '@mantine/dates';

function Demo() {
  return (
    <Stack>
      <DateTimePicker dropdownType="drawer" label="Drawer" placeholder="Pick date and time" />
      <DateTimePicker dropdownType="modal" label="Modal" placeholder="Pick date and time" />
      <DateTimePicker dropdownType="popover" label="Popover" placeholder="Pick date and time" />
      <DateTimePicker
        dropdownType={{ base: 'drawer', 600: 'popover' }}
        label="Drawer below 600px, popover above"
        placeholder="Pick date and time"
      />
    </Stack>
  );
}
```


## Dropzone upload progress

[Dropzone](https://alpha.mantine.dev/llms/x-dropzone.md#upload-progress) now supports the `progress` prop to display upload progress inside the dropzone.
While it is set, the dropzone is disabled and `Dropzone.Uploading` is displayed instead of `Dropzone.Idle`:

```tsx
import { useEffect, useRef, useState } from 'react';
import { CloudArrowUpIcon, ImageIcon, UploadSimpleIcon, XIcon } from '@phosphor-icons/react';
import { Group, Text } from '@mantine/core';
import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from '@mantine/dropzone';

function Demo() {
  const [progress, setProgress] = useState<number | undefined>(undefined);
  const interval = useRef<number>(undefined);

  useEffect(() => () => window.clearInterval(interval.current), []);

  const upload = (files: FileWithPath[]) => {
    if (files.length === 0) {
      return;
    }

    let uploaded = 0;
    setProgress(uploaded);

    interval.current = window.setInterval(() => {
      uploaded += 10;

      if (uploaded > 100) {
        window.clearInterval(interval.current);
        setProgress(undefined);
      } else {
        setProgress(uploaded);
      }
    }, 200);
  };

  return (
    <Dropzone
      accept={IMAGE_MIME_TYPE}
      onDrop={upload}
      progress={progress}
      progressProps={{ 'aria-label': 'Upload progress' }}
    >
      <Group justify="center" gap="xl" mih={220} style={{ pointerEvents: 'none' }}>
        <Dropzone.Accept>
          <UploadSimpleIcon size={52} color="var(--mantine-color-blue-6)" />
        </Dropzone.Accept>

        <Dropzone.Reject>
          <XIcon size={52} color="var(--mantine-color-red-6)" />
        </Dropzone.Reject>

        <Dropzone.Idle>
          <ImageIcon size={52} color="var(--mantine-color-dimmed)" />
        </Dropzone.Idle>

        <Dropzone.Uploading>
          <CloudArrowUpIcon size={52} color="var(--mantine-color-blue-6)" />
        </Dropzone.Uploading>

        <Text size="xl" inline>
          {progress === undefined
            ? 'Drag images here or click to select files'
            : `Uploading… ${progress}%`}
        </Text>
      </Group>
    </Dropzone>
  );
}
```


## Modal and Drawer updates

Use `Modal.Footer` or `Drawer.Footer` to keep actions visible while the body scrolls. Set `stickyHeader={false}` or `stickyFooter={false}` to scroll that section with the content:

```tsx
import { useDisclosure } from '@mantine/hooks';
import { Modal, Button, Group, Text } from '@mantine/core';

function Demo() {
  const [opened, { open, close }] = useDisclosure(false);

  return (
    <>
      <Modal.Root opened={opened} onClose={close}>
        <Modal.Overlay />
        <Modal.Content>
          <Modal.Header>
            <Modal.Title>Terms of service</Modal.Title>
            <Modal.CloseButton />
          </Modal.Header>

          <Modal.Body>
            {Array.from({ length: 20 }).map((_, index) => (
              <Text key={index} mb="md">
                Scroll the body to see that the header stays pinned to the top and the footer
                stays pinned to the bottom.
              </Text>
            ))}
          </Modal.Body>

          <Modal.Footer>
            <Group justify="flex-end" w="100%">
              <Button variant="default" onClick={close}>
                Decline
              </Button>
              <Button onClick={close}>Accept</Button>
            </Group>
          </Modal.Footer>
        </Modal.Content>
      </Modal.Root>

      <Button variant="default" onClick={open}>
        Open modal
      </Button>
    </>
  );
}
```


`Modal.Stack` and `Drawer.Stack` now keep earlier overlays visible behind the top one. Set `maxDepth` to choose how many stay visible:

```tsx
import { Button, Group, Modal, useModalsStack } from '@mantine/core';

function Demo() {
  const stack = useModalsStack(['delete-page', 'confirm-action', 'really-confirm-action']);

  return (
    <>
      <Modal.Stack>
        <Modal {...stack.register('delete-page')} title="Delete this page?">
          Are you sure you want to delete this page? This action cannot be undone.
          <Group mt="lg" justify="flex-end">
            <Button onClick={stack.closeAll} variant="default">
              Cancel
            </Button>
            <Button onClick={() => stack.open('confirm-action')} color="red">
              Delete
            </Button>
          </Group>
        </Modal>

        <Modal {...stack.register('confirm-action')} title="Confirm action">
          Are you sure you want to perform this action? This action cannot be undone. If you are
          sure, press confirm button below.
          <Group mt="lg" justify="flex-end">
            <Button onClick={stack.closeAll} variant="default">
              Cancel
            </Button>
            <Button onClick={() => stack.open('really-confirm-action')} color="red">
              Confirm
            </Button>
          </Group>
        </Modal>

        <Modal {...stack.register('really-confirm-action')} title="Really confirm action">
          Jokes aside. You have confirmed this action. This is your last chance to cancel it. After
          you press confirm button below, action will be performed and cannot be undone. For real
          this time. Are you sure you want to proceed?
          <Group mt="lg" justify="flex-end">
            <Button onClick={stack.closeAll} variant="default">
              Cancel
            </Button>
            <Button onClick={stack.closeAll} color="red">
              Confirm
            </Button>
          </Group>
        </Modal>
      </Modal.Stack>

      <Button variant="default" onClick={() => stack.open('delete-page')}>
        Open modal
      </Button>
    </>
  );
}
```


## Automatic Modal and Drawer stacking

Set `overlayStack` in the theme to stack all modals and drawers without `Modal.Stack` wrappers:

```tsx
import { createTheme } from '@mantine/core';

const theme = createTheme({
  overlayStack: true,
});
```

```tsx
import { Button, Group, Modal, useModalStackContext } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';

function Demo() {
  const [deleteOpened, deleteHandlers] = useDisclosure(false);
  const [confirmOpened, confirmHandlers] = useDisclosure(false);
  const stack = useModalStackContext();

  return (
    <>
      <Modal opened={deleteOpened} onClose={deleteHandlers.close} title="Delete this page?">
        Are you sure you want to delete this page? This action cannot be undone.
        <Group mt="lg" justify="flex-end">
          <Button onClick={deleteHandlers.close} variant="default">
            Cancel
          </Button>
          <Button onClick={confirmHandlers.open} color="red">
            Delete
          </Button>
        </Group>
      </Modal>

      <Modal opened={confirmOpened} onClose={confirmHandlers.close} title="Confirm action">
        Are you sure you want to perform this action? This action cannot be undone. If you are
        sure, press confirm button below.
        <Group mt="lg" justify="flex-end">
          <Button onClick={stack.closeAll} variant="default">
            Cancel
          </Button>
          <Button onClick={stack.closeAll} color="red">
            Confirm
          </Button>
        </Group>
      </Modal>

      <Button variant="default" onClick={deleteHandlers.open}>
        Open modal
      </Button>
    </>
  );
}
```


## useModal and useDrawer hooks

New [useModal](https://alpha.mantine.dev/llms/core-modal.md#usemodal-hook) and `useDrawer` hooks open a modal or a drawer
without rendering it in JSX:

```tsx
import { useState } from 'react';
import { Button, Group, Text, useModal } from '@mantine/core';

function Demo() {
  const [count, setCount] = useState(0);
  const modal = useModal({
    title: `Count: ${count}`,
    children: (
      <>
        <Text mb="md">The modal is updated every time the parent component renders: {count}</Text>
        <Button fullWidth onClick={() => setCount((c) => c + 1)}>
          Increment
        </Button>
      </>
    ),
  });

  return (
    <Group justify="center">
      <Button onClick={() => modal.open()}>Open modal</Button>
      <Button variant="default" onClick={() => setCount((c) => c + 1)}>
        Increment ({count})
      </Button>
    </Group>
  );
}
```


Pass props to `open` to change the content or settings for one opening:

```tsx
import { useState } from 'react';
import { Button, Group, Text, useDrawer } from '@mantine/core';

function Demo() {
  const [count, setCount] = useState(0);
  const drawer = useDrawer({
    title: `Count: ${count}`,
    position: 'right',
    children: (
      <>
        <Text mb="md">The drawer is updated every time the parent component renders: {count}</Text>
        <Button fullWidth onClick={() => setCount((c) => c + 1)}>
          Increment
        </Button>
      </>
    ),
  });

  return (
    <Group justify="center">
      <Button onClick={() => drawer.open()}>Open drawer</Button>
      <Button variant="default" onClick={() => drawer.open({ position: 'left' })}>
        Open on the left
      </Button>
      <Button variant="default" onClick={() => setCount((c) => c + 1)}>
        Increment ({count})
      </Button>
    </Group>
  );
}
```


## Modal and Drawer close guard

New [useModalCloseGuard](https://alpha.mantine.dev/llms/core-modal.md#close-guard) and `useDrawerCloseGuard` hooks are called inside
modal content to keep the modal opened while a form is submitting or to ask before discarding changes:

```tsx
import { useRef } from 'react';
import { Button, Group, Textarea, TextInput, useModal, useModalCloseGuard } from '@mantine/core';
import { useForm } from '@mantine/form';

function NoteForm({ onSave }: { onSave: () => void }) {
  const form = useForm({ initialValues: { title: '', text: '' } });
  const resolveRef = useRef<((discard: boolean) => void) | null>(null);

  const settle = (discard: boolean) => {
    resolveRef.current?.(discard);
    resolveRef.current = null;
  };

  const confirm = useModal({
    title: 'Discard changes?',
    size: 'sm',
    onClose: () => settle(false),
    children: (
      <Group justify="flex-end">
        <Button variant="default" onClick={() => confirm.close()}>
          Keep editing
        </Button>
        <Button
          color="red"
          onClick={() => {
            settle(true);
            confirm.close();
          }}
        >
          Discard
        </Button>
      </Group>
    ),
  });

  // Called before the modal is closed with the close button, Escape or overlay click
  const closeModal = useModalCloseGuard(
    () =>
      !form.isDirty() ||
      new Promise<boolean>((resolve) => {
        resolveRef.current = resolve;
        confirm.open();
      })
  );

  return (
    <form onSubmit={form.onSubmit(onSave)}>
      <TextInput label="Title" placeholder="Title" data-autofocus {...form.getInputProps('title')} />
      <Textarea label="Text" placeholder="Text" mt="md" {...form.getInputProps('text')} />
      <Group justify="flex-end" mt="md">
        <Button variant="default" onClick={closeModal}>
          Cancel
        </Button>
        <Button type="submit">Save</Button>
      </Group>
    </form>
  );
}

function Demo() {
  const modal = useModal({
    title: 'Edit note',
    children: <NoteForm onSave={() => modal.close()} />,
  });

  return <Button onClick={() => modal.open()}>Edit note</Button>;
}
```


## Drawer swipe to dismiss

[Drawer](https://alpha.mantine.dev/llms/core-drawer.md) can now be closed with a swipe. It is enabled by default,
set `withSwipe={false}` to disable it:

```tsx
import { useDisclosure } from '@mantine/hooks';
import { Drawer, Button, Text } from '@mantine/core';

function Demo() {
  const [opened, { open, close }] = useDisclosure(false);

  return (
    <>
      <Drawer
        opened={opened}
        onClose={close}
        position="bottom"
        title="Swipe to dismiss"
        withCloseButton={false}
        withHandle
      >
        <Text>Drag the handle or swipe the drawer down to close it.</Text>
      </Drawer>

      <Button variant="default" onClick={open}>
        Open Drawer
      </Button>
    </>
  );
}
```


## Drawer snap points

New `snapPoints` prop lets the [Drawer](https://alpha.mantine.dev/llms/core-drawer.md) stop at several sizes:

```tsx
import { useDisclosure } from '@mantine/hooks';
import { Drawer, Button, Text } from '@mantine/core';

function Demo() {
  const [opened, { open, close }] = useDisclosure(false);

  return (
    <>
      <Drawer
        opened={opened}
        onClose={close}
        position="bottom"
        title="Snap points"
        snapPoints={[0.4, 0.75, 1]}
        defaultActiveSnapPoint={0.4}
        withCloseButton={false}
        withHandle
        dragHandlePosition="inside"
      >
        <Text>Drag the drawer up and down to snap it to 40%, 75% or 100% of the screen height.</Text>
      </Drawer>

      <Button variant="default" onClick={open}>
        Open Drawer
      </Button>
    </>
  );
}
```


## Menu filled variant and item description

New `variant="filled"` of [Menu](https://alpha.mantine.dev/llms/core-menu.md) highlights the hovered item with the primary color:

```tsx
import { Menu, Button, Text } from '@mantine/core';
import { GearSixIcon, MagnifyingGlassIcon, ImageIcon, ChatCircleIcon, TrashIcon, ArrowsLeftRightIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <Menu variant="filled" shadow="md" width={200}>
      <Menu.Target>
        <Button variant="default">Toggle menu</Button>
      </Menu.Target>

      <Menu.Dropdown>
        <Menu.Label>Application</Menu.Label>
        <Menu.Item leftSection={<GearSixIcon size={14} />}>
          Settings
        </Menu.Item>
        <Menu.Item leftSection={<ChatCircleIcon size={14} />}>
          Messages
        </Menu.Item>
        <Menu.Item leftSection={<ImageIcon size={14} />}>
          Gallery
        </Menu.Item>
        <Menu.Item
          leftSection={<MagnifyingGlassIcon size={14} />}
          rightSection={
            <Text size="xs" opacity={0.6}>
              ⌘K
            </Text>
          }
        >
          Search
        </Menu.Item>

        <Menu.Divider />

        <Menu.Label>Danger zone</Menu.Label>
        <Menu.Item
          leftSection={<ArrowsLeftRightIcon size={14} />}
        >
          Transfer my data
        </Menu.Item>
        <Menu.Item
          color="red"
          leftSection={<TrashIcon size={14} />}
        >
          Delete my account
        </Menu.Item>
      </Menu.Dropdown>
    </Menu>
  );
}
```


New `description` prop of `Menu.Item` displays a second line of text below the label:

```tsx
import { BellIcon, LinkIcon, TrashIcon, UserPlusIcon } from '@phosphor-icons/react';
import { Button, Menu } from '@mantine/core';

function Demo() {
  return (
    <Menu shadow="md" width={260}>
      <Menu.Target>
        <Button variant="default">Share</Button>
      </Menu.Target>

      <Menu.Dropdown>
        <Menu.Label>Share</Menu.Label>
        <Menu.Item
          leftSection={<LinkIcon size={14} />}
          description="Anyone with the link can view"
        >
          Copy link
        </Menu.Item>
        <Menu.Item
          leftSection={<UserPlusIcon size={14} />}
          description="Send an email invitation"
        >
          Invite people
        </Menu.Item>
        <Menu.Item
          leftSection={<BellIcon size={14} />}
          description="Digest, mentions or everything"
        >
          Notifications
        </Menu.Item>

        <Menu.Divider />

        <Menu.Item
          color="red"
          leftSection={<TrashIcon size={14} />}
          description="Moves the file to trash"
        >
          Delete file
        </Menu.Item>
      </Menu.Dropdown>
    </Menu>
  );
}
```


## Menu async data

New `Menu.Empty` component displays a message when the menu has no items, for example
while items are loading or when search returns nothing:

```tsx
import { useState } from 'react';
import { Button, Group, Loader, Menu } from '@mantine/core';

function getRecentFiles() {
  return new Promise<string[]>((resolve) => {
    setTimeout(
      () => resolve(['Quarterly report.pdf', 'Roadmap 2027.key', 'Invoices.xlsx', 'Logo.svg']),
      1500
    );
  });
}

function Demo() {
  const [files, setFiles] = useState<string[] | null>(null);
  const [loading, setLoading] = useState(false);

  const handleOpen = () => {
    setLoading(true);
    getRecentFiles().then((result) => {
      setFiles(result);
      setLoading(false);
    });
  };

  return (
    <Menu width={240} onOpen={handleOpen}>
      <Menu.Target>
        <Button variant="default">Recent files</Button>
      </Menu.Target>

      <Menu.Dropdown>
        {loading && (
          <Menu.Empty>
            <Group gap="xs" justify="center">
              <Loader size={14} />
              Loading recent files
            </Group>
          </Menu.Empty>
        )}

        {!loading && files?.length === 0 && <Menu.Empty>No recent files</Menu.Empty>}

        {!loading && files?.map((file) => <Menu.Item key={file}>{file}</Menu.Item>)}
      </Menu.Dropdown>
    </Menu>
  );
}
```


New `Menu.LoadMore` component loads the next page of items when it is scrolled into view,
focused or clicked:

```tsx
import { useState } from 'react';
import { Button, Menu } from '@mantine/core';

const PAGE_SIZE = 8;
const TOTAL = 40;

function getUsers(page: number) {
  return new Promise<string[]>((resolve) => {
    setTimeout(() => {
      resolve(
        Array.from({ length: PAGE_SIZE }, (_, index) => `User ${page * PAGE_SIZE + index + 1}`)
      );
    }, 800);
  });
}

function Demo() {
  const [users, setUsers] = useState<string[]>([]);
  const [loading, setLoading] = useState(false);

  const loadMore = () => {
    setLoading(true);
    getUsers(users.length / PAGE_SIZE).then((page) => {
      setUsers((current) => [...current, ...page]);
      setLoading(false);
    });
  };

  return (
    <Menu width={220}>
      <Menu.Target>
        <Button variant="default">Assign to user</Button>
      </Menu.Target>

      <Menu.Dropdown>
        <Menu.ScrollArea mah={260}>
          {users.map((user) => (
            <Menu.Item key={user}>{user}</Menu.Item>
          ))}

          {users.length < TOTAL && (
            <Menu.LoadMore onLoadMore={loadMore} loading={loading}>
              {loading ? 'Loading users' : 'Load more users'}
            </Menu.LoadMore>
          )}
        </Menu.ScrollArea>
      </Menu.Dropdown>
    </Menu>
  );
}
```


## Collapsible breadcrumbs

[Breadcrumbs](https://alpha.mantine.dev/llms/core-breadcrumbs.md#collapsing-items) can now move links into a menu when the trail no longer fits on one line:

```tsx
import { Anchor, Box, Breadcrumbs } from '@mantine/core';

function Demo() {
  return (
    <Box w={340} maw="100%" py={4} style={{ resize: 'horizontal', overflow: 'auto' }}>
      <Breadcrumbs collapse${props}>
        <Anchor href="/">Mantine</Anchor>
        <Anchor href="/core/package/">Components</Anchor>
        <Anchor href="/core/breadcrumbs/">Breadcrumbs</Anchor>
        <span aria-current="page">Collapsing items</span>
      </Breadcrumbs>
    </Box>
  );
}
```


## NavLink redesign

[NavLink](https://alpha.mantine.dev/llms/core-nav-link.md) has a new look and a `rail` variant that marks the active link with a bar.
Set `withGuideline` to display a guideline next to nested links:

```tsx
import { FolderIcon, GaugeIcon, GearIcon, UsersIcon } from '@phosphor-icons/react';
import { Box, NavLink } from '@mantine/core';

function Demo() {
  return (
    <Box w={240}>
      <NavLink
        href="#required-for-focus"
        label="Dashboard"
        leftSection={<GaugeIcon size={16} />}
        variant="rail"
      />
      <NavLink
        label="Projects"
        leftSection={<FolderIcon size={16} />}
        variant="rail"
        withGuideline
        defaultOpened
      >
        <NavLink href="#required-for-focus" label="Website" variant="rail" active />
        <NavLink href="#required-for-focus" label="Mobile app" variant="rail" />
        <NavLink href="#required-for-focus" label="Design system" variant="rail" />
      </NavLink>
      <NavLink
        href="#required-for-focus"
        label="Team"
        leftSection={<UsersIcon size={16} />}
        variant="rail"
      />
      <NavLink
        href="#required-for-focus"
        label="Settings"
        leftSection={<GearIcon size={16} />}
        variant="rail"
      />
    </Box>
  );
}
```


New `size` prop controls font size and spacing:

```tsx
function Demo() {
  return (
    <Box w={260}>
      <NavLink
        href="#required-for-focus"
        label="Dashboard"
        leftSection={<GaugeIcon size={${iconSize}} />}${sizeProp}
      />
      <NavLink
        label="Projects"
        leftSection={<FolderIcon size={${iconSize}} />}${sizeProp}
        defaultOpened
      >
        <NavLink href="#required-for-focus" label="Website"${sizeProp} active />
        <NavLink href="#required-for-focus" label="Mobile app"${sizeProp} />
      </NavLink>
      <NavLink
        href="#required-for-focus"
        label="Team"
        description="12 members"
        leftSection={<UsersIcon size={${iconSize}} />}${sizeProp}
      />
    </Box>
  );
}
```


## TableOfContents rail variant

[TableOfContents](https://alpha.mantine.dev/llms/core-table-of-contents.md) has a new default `rail` variant and a smaller default size:

```tsx
import { TableOfContents } from '@mantine/core';


function Demo() {
  return (
    <TableOfContents
       variant="rail" color="blue" size="sm" radius="md" withGuideline={true}
      scrollSpyOptions={{
        selector: '#mdx :is(h1, h2, h3, h4, h5, h6)',
      }}
    />
  );
}
```


## Tree keyboard drag and drop

[Tree](https://alpha.mantine.dev/llms/core-tree.md#keyboard) nodes can now be moved with the keyboard when `onDragDrop` is set.
`Ctrl` + arrow key (`Cmd` + arrow key on macOS) picks up the focused node, arrow keys move it,
`Enter` drops it and `Escape` cancels the move. Screen readers announce every step,
use the new `labels` prop to translate the announcements:

```tsx
import { useState } from 'react';
import { FileTextIcon, FolderOpenIcon, FolderSimpleIcon } from '@phosphor-icons/react';
import { Group, moveTreeNode, RenderTreeNodePayload, Tree, TreeNodeData } from '@mantine/core';

const data: TreeNodeData[] = [
  {
    label: 'Pages',
    value: 'pages',
    children: [
      { label: 'index.tsx', value: 'pages/index.tsx' },
      { label: 'about.tsx', value: 'pages/about.tsx' },
      { label: 'contact.tsx', value: 'pages/contact.tsx' },
    ],
  },
  {
    label: 'Components',
    value: 'components',
    children: [
      { label: 'Header.tsx', value: 'components/Header.tsx' },
      { label: 'Footer.tsx', value: 'components/Footer.tsx' },
      { label: 'Sidebar.tsx', value: 'components/Sidebar.tsx' },
    ],
  },
  { label: 'package.json', value: 'package.json' },
  { label: 'tsconfig.json', value: 'tsconfig.json' },
];

function Leaf({ node, expanded, hasChildren, elementProps }: RenderTreeNodePayload) {
  return (
    <Group gap={6} {...elementProps}>
      {hasChildren ? (
        expanded ? (
          <FolderOpenIcon size={14} style={{ opacity: 0.75 }} />
        ) : (
          <FolderSimpleIcon size={14} style={{ opacity: 0.75 }} />
        )
      ) : (
        <FileTextIcon size={14} style={{ opacity: 0.75 }} />
      )}
      <span>{node.label}</span>
    </Group>
  );
}

function Demo() {
  const [treeData, setTreeData] = useState(data);

  return (
    <Tree
      data={treeData}
      withLines
      onDragDrop={(payload) =>
        setTreeData((current) => moveTreeNode(current, payload))
      }
      renderNode={(payload) => <Leaf {...payload} />}
    />
  );
}
```


## Tabs variants

[Tabs](https://alpha.mantine.dev/llms/core-tabs.md) now support four new variants: `inset`, `pill-compact`, `contained` and `enclosed`:

```tsx
import { Stack, Tabs, TabsVariant } from '@mantine/core';
import { ImageIcon, ChatCircleIcon, GearSixIcon } from '@phosphor-icons/react';

const variants: TabsVariant[] = ['inset', 'pill-compact', 'contained', 'enclosed'];

function Demo() {
  return (
    <Stack gap="xl">
      {variants.map((variant) => {
        const pt = variant === 'enclosed' ? undefined : 'xs';

        return (
          <Tabs key={variant} variant={variant} defaultValue="gallery">
            <Tabs.List>
              <Tabs.Tab value="gallery" leftSection={<ImageIcon size={12} />}>
                Gallery
              </Tabs.Tab>
              <Tabs.Tab value="messages" leftSection={<ChatCircleIcon size={12} />}>
                Messages
              </Tabs.Tab>
              <Tabs.Tab value="settings" leftSection={<GearSixIcon size={12} />}>
                Settings
              </Tabs.Tab>
            </Tabs.List>

            <Tabs.Panel value="gallery" pt={pt}>
              Gallery tab content
            </Tabs.Panel>
            <Tabs.Panel value="messages" pt={pt}>
              Messages tab content
            </Tabs.Panel>
            <Tabs.Panel value="settings" pt={pt}>
              Settings tab content
            </Tabs.Panel>
          </Tabs>
        );
      })}
    </Stack>
  );
}
```


## Stepper redesign

[Stepper](https://alpha.mantine.dev/llms/core-stepper.md) has a new look:

```tsx
import { useState } from 'react';
import { Stepper, Button, Group } from '@mantine/core';

function Demo() {
  const [active, setActive] = useState(1);
  const nextStep = () => setActive((current) => (current < 3 ? current + 1 : current));
  const prevStep = () => setActive((current) => (current > 0 ? current - 1 : current));

  return (
    <>
      <Stepper active={active} onStepClick={setActive}>
        <Stepper.Step label="First step" description="Create an account">
          Step 1 content: Create an account
        </Stepper.Step>
        <Stepper.Step label="Second step" description="Verify email">
          Step 2 content: Verify email
        </Stepper.Step>
        <Stepper.Step label="Final step" description="Get full access">
          Step 3 content: Get full access
        </Stepper.Step>
        <Stepper.Completed>
          Completed, click back button to get to previous step
        </Stepper.Completed>
      </Stepper>

      <Group justify="center" mt="xl">
        <Button variant="default" onClick={prevStep}>Back</Button>
        <Button onClick={nextStep}>Next step</Button>
      </Group>
    </>
  );
}
```


## Slider thumb redesign

[Slider](https://alpha.mantine.dev/llms/core-slider.md) and [RangeSlider](https://alpha.mantine.dev/llms/core-range-slider.md) have a new thumb:

```tsx
import { RangeSlider, Slider, Stack } from '@mantine/core';

function Demo() {
  return (
    <Stack gap="xl">
      <Slider defaultValue={40} variant="default" color="blue" size="md" />
      <RangeSlider defaultValue={[20, 60]} variant="default" color="blue" size="md" />
    </Stack>
  );
}
```


## Blockquote redesign

[Blockquote](https://alpha.mantine.dev/llms/core-blockquote.md) has a new look:

```tsx
import { Blockquote } from '@mantine/core';
import { InfoIcon } from '@phosphor-icons/react';

function Demo() {
  const icon = <InfoIcon />;
  return (
    <Blockquote color="blue" iconSize={24} cite="– Forrest Gump" icon={icon}>
      Life is like an npm install – you never know what you are going to get.
    </Blockquote>
  );
}
```


## Alert redesign

[Alert](https://alpha.mantine.dev/llms/core-alert.md) has a new look:

```tsx
import { CheckCircleIcon, InfoIcon, WarningIcon, XCircleIcon } from '@phosphor-icons/react';
import { Alert, Stack } from '@mantine/core';

function Demo() {
  return (
    <Stack>
      <Alert
        color="blue"
        icon={<InfoIcon />}
        title="Payment method expires soon"
        withCloseButton
        closeButtonLabel="Dismiss"
      >
        The card ending in 4242 expires on 30 September. Update it to keep your subscription
        active.
      </Alert>

      <Alert color="teal" icon={<CheckCircleIcon />} title="Changes saved">
        Your notification preferences were updated.
      </Alert>

      <Alert color="yellow" icon={<WarningIcon />} title="Storage almost full">
        You have used 92% of your 50 GB plan. Delete files or upgrade to keep uploading.
      </Alert>

      <Alert color="red" icon={<XCircleIcon />} title="Build failed">
        Two required environment variables are missing: DATABASE_URL and SESSION_SECRET.
      </Alert>
    </Stack>
  );
}
```


## Notification redesign

[Notification](https://alpha.mantine.dev/llms/core-notification.md) has a new look:

```tsx
import { CheckIcon } from '@phosphor-icons/react';
import { Notification, Stack } from '@mantine/core';

function Demo() {
  const icon = <CheckIcon />;

  return (
    <Stack>
      <Notification variant="filled" icon={icon} color="teal" title="Changes saved">
        Your profile was updated
      </Notification>
      <Notification variant="light" icon={icon} color="teal" title="Changes saved">
        Your profile was updated
      </Notification>
      <Notification variant="transparent" icon={icon} color="teal" title="Changes saved">
        Your profile was updated
      </Notification>
    </Stack>
  );
}
```


## Compact notifications

The [Notifications](https://alpha.mantine.dev/llms/x-notifications.md#snackbar-presentation) component now supports a compact snackbar presentation for brief confirmations:

```tsx
import { CheckIcon, XIcon } from '@phosphor-icons/react';
import { Button, Group, ThemeIcon } from '@mantine/core';
import { createNotificationsStore, Notifications, notifications } from '@mantine/notifications';

const store = createNotificationsStore();

function Demo() {
  return (
    <>
      <Notifications store={store} presentation="snackbar" />
      <Group justify="center">
        <Button onClick={() => notifications.show({ message: 'Note added', icon: '✓' }, store)}>
          Add note
        </Button>
        <Button
          color="red"
          onClick={() =>
            notifications.show(
              {
                message: 'Could not save note',
                icon: (
                  <ThemeIcon color="red" radius="xl" size="sm">
                    <XIcon size={14} />
                  </ThemeIcon>
                ),
              },
              store
            )
          }
        >
          Danger
        </Button>
        <Button
          color="teal"
          onClick={() =>
            notifications.show(
              {
                message: 'Note saved',
                icon: (
                  <ThemeIcon color="teal" radius="xl" size="sm">
                    <CheckIcon size={14} />
                  </ThemeIcon>
                ),
              },
              store
            )
          }
        >
          Success
        </Button>
      </Group>
    </>
  );
}
```


## use-hold-repeat and use-hold-repeat-handlers hooks

[use-hold-repeat](https://alpha.mantine.dev/llms/hooks-use-hold-repeat.md) repeats an action while a control is held, with an optional accelerating interval.
Use [use-hold-repeat-handlers](https://alpha.mantine.dev/llms/hooks-use-hold-repeat-handlers.md) to attach pointer and keyboard handlers to the control:

```tsx
import { useState } from 'react';
import { MinusIcon, PlusIcon } from '@phosphor-icons/react';
import { ActionIcon, Group, Text } from '@mantine/core';
import { useHoldRepeatHandlers } from '@mantine/hooks';

const interval = (step: number) => Math.max(40, 300 - step * 20);

function Demo() {
  const [count, setCount] = useState(0);

  const increment = useHoldRepeatHandlers(() => setCount((c) => c + 1), { delay: 400, interval });
  const decrement = useHoldRepeatHandlers(() => setCount((c) => c - 1), { delay: 400, interval });

  return (
    <Group>
      <ActionIcon {...decrement} variant="default" size="lg" aria-label="Decrement">
        <MinusIcon size={18} />
      </ActionIcon>
      <Text fw={500} w={60} ta="center">{count}</Text>
      <ActionIcon {...increment} variant="default" size="lg" aria-label="Increment">
        <PlusIcon size={18} />
      </ActionIcon>
    </Group>
  );
}
```


## use-debounced-effect and use-throttled-effect hooks

[use-debounced-effect](https://alpha.mantine.dev/llms/hooks-use-debounced-effect.md) runs an effect after its dependencies stop changing.
Use [use-throttled-effect](https://alpha.mantine.dev/llms/hooks-use-throttled-effect.md) to run it at most once per interval while they change:

```tsx
import { useState } from 'react';
import { Badge, Group, Stack, Text, TextInput } from '@mantine/core';
import { useDebouncedEffect } from '@mantine/hooks';

function Demo() {
  const [query, setQuery] = useState('');
  const [runs, setRuns] = useState(0);
  const [lastQuery, setLastQuery] = useState('');

  useDebouncedEffect(
    () => {
      setRuns((current) => current + 1);
      setLastQuery(query);
    },
    [query],
    500
  );

  return (
    <Stack>
      <TextInput
        label="Type quickly – the effect runs 500ms after you stop"
        placeholder="Search..."
        value={query}
        onChange={(event) => setQuery(event.currentTarget.value)}
      />
      <Group>
        <Badge>Effect runs: {runs}</Badge>
        <Text size="sm">Last searched: {lastQuery || '–'}</Text>
      </Group>
    </Stack>
  );
}
```


## use-clipboard blobs and images support

[use-clipboard](https://alpha.mantine.dev/llms/hooks-use-clipboard.md) can now copy images and other binary data from a `Blob`, `ClipboardItem` or `ClipboardItem[]`.
Check `supported` before offering to copy an image:

```tsx
import { useEffect, useRef } from 'react';
import { useClipboard } from '@mantine/hooks';
import { Button, Stack } from '@mantine/core';

function Demo() {
  const clipboard = useClipboard();
  const canvasRef = useRef<HTMLCanvasElement>(null);

  useEffect(() => {
    const ctx = canvasRef.current?.getContext('2d');
    if (!ctx) {
      return;
    }

    const gradient = ctx.createLinearGradient(0, 0, 240, 120);
    gradient.addColorStop(0, '#4c6ef5');
    gradient.addColorStop(1, '#e64980');
    ctx.fillStyle = gradient;
    ctx.fillRect(0, 0, 240, 120);
    ctx.fillStyle = 'white';
    ctx.font = 'bold 22px sans-serif';
    ctx.fillText('Mantine', 20, 68);
  }, []);

  const copyImage = () => {
    const canvas = canvasRef.current;
    if (!canvas) {
      return;
    }

    // Construct the ClipboardItem with a Promise synchronously so that the write
    // stays within the user gesture (required by Safari)
    const blob = new Promise<Blob>((resolve, reject) => {
      canvas.toBlob(
        (result) => (result ? resolve(result) : reject(new Error('Failed to export image'))),
        'image/png'
      );
    });

    clipboard.copy(new ClipboardItem({ 'image/png': blob }));
  };

  return (
    <Stack align="center">
      <canvas ref={canvasRef} width={240} height={120} style={{ borderRadius: 8 }} />
      <Button
        color={clipboard.copied ? 'teal' : undefined}
        disabled={!clipboard.supported}
        onClick={copyImage}
      >
        {clipboard.copied ? 'Image copied' : 'Copy image'}
      </Button>
    </Stack>
  );
}
```


## use-broadcast-channel hook

New [use-broadcast-channel](https://alpha.mantine.dev/llms/hooks-use-broadcast-channel.md) sends and receives messages across tabs, windows, frames and workers on the same origin.
Open the demo in two tabs to try it:

```tsx
import { useBroadcastChannel } from '@mantine/hooks';
import { Badge, Button, Group, Paper, Text } from '@mantine/core';

const reactions = ['👋', '🎉', '☕', '🚀'];

function Panel({ label }: { label: string }) {
  const { supported, data, post } = useBroadcastChannel<string>('mantine-demo-channel');

  return (
    <Paper withBorder p="md" flex={1}>
      <Group justify="space-between" mb="md">
        <Text fw={500}>{label}</Text>
        <Badge color={supported ? 'teal' : 'red'} variant="light">
          {supported ? 'supported' : 'unsupported'}
        </Badge>
      </Group>

      <Text size="sm" c="dimmed">Last received</Text>
      <Text fz={32}>{data ?? '—'}</Text>

      <Group mt="md" gap="xs">
        {reactions.map((reaction) => (
          <Button key={reaction} variant="default" onClick={() => post(reaction)}>
            {reaction}
          </Button>
        ))}
      </Group>
    </Paper>
  );
}

// Both panels create their own channel with the same name, so a message posted
// from one is delivered to the other (but never back to the sender). Open this
// page in a second browser tab to see the reactions sync across tabs as well.
function Demo() {
  return (
    <Group align="stretch" grow>
      <Panel label="Tab A" />
      <Panel label="Tab B" />
    </Group>
  );
}
```


## Other changes

**Appearance and theming**

* [Chip](https://alpha.mantine.dev/llms/core-chip.md), [Switch](https://alpha.mantine.dev/llms/core-switch.md) and [Slider](https://alpha.mantine.dev/llms/core-slider.md) now follow `theme.autoContrast`: chip text, switch thumb and inner labels, filled slider thumb icons adjust to the control color.
* [Slider](https://alpha.mantine.dev/llms/core-slider.md) and [RangeSlider](https://alpha.mantine.dev/llms/core-range-slider.md) marks on the filled part of the track follow `autoContrast`.
* Selected options in [Combobox](https://alpha.mantine.dev/llms/core-combobox.md) dropdowns and active [TimePicker](https://alpha.mantine.dev/llms/dates-time-picker.md) controls use the primary color contrast color.
* [ColorPicker](https://alpha.mantine.dev/llms/core-color-picker.md) now follows `theme.defaultRadius`.
* [JsonViewer](https://alpha.mantine.dev/llms/code-highlight-json-viewer.md) now uses the same syntax colors as `CodeHighlight` in both light and dark color schemes.
* [Alert](https://alpha.mantine.dev/llms/core-alert.md) now supports `size` and `closeButtonProps` props.
* [Avatar.Group](https://alpha.mantine.dev/llms/core-avatar.md) now supports `max` prop: avatars that do not fit are replaced with a `+N` counter.
* [Badge](https://alpha.mantine.dev/llms/core-badge.md) with `variant="dot"` no longer renders `leftSection`.
* [RingProgress](https://alpha.mantine.dev/llms/core-ring-progress.md#segments) now supports `segments` prop to divide the ring into equal parts.
* The [Switch](https://alpha.mantine.dev/llms/core-switch.md) thumb now stretches while pressed.
* [Kbd](https://alpha.mantine.dev/llms/core-kbd.md) now looks like a raised keycap in both light and dark color schemes.

**Inputs and dates**

* [Input](https://alpha.mantine.dev/llms/core-input.md) rendered inside another input's section (for example, `NativeSelect` in the `rightSection` of `NumberInput`) no longer inherits the outer input's section width, error color and size styles.
* [Input.Wrapper](https://alpha.mantine.dev/llms/core-input.md#withblockchildren) now supports `withBlockChildren` prop to render non-input children with the same spacing as inputs.
* [Textarea](https://alpha.mantine.dev/llms/core-textarea.md#bottom-section) `bottomSection` no longer blocks clicks: a click on it focuses the textarea. Set `bottomSectionPointerEvents="all"` for interactive content.
* [AngleSlider](https://alpha.mantine.dev/llms/core-angle-slider.md) now supports `largeStep` and `readOnly` props and `PageUp`/`PageDown` keys.
* [JsonInput](https://alpha.mantine.dev/llms/core-json-input.md) now disables browser spellcheck, autocorrect and grammar extensions (Grammarly, LanguageTool) on its textarea.
* [NumberInput](https://alpha.mantine.dev/llms/core-number-input.md#controls-position) now supports `controlsPosition="sides"` to display the decrement button on the left and the increment button on the right.
* [PasswordInput](https://alpha.mantine.dev/llms/core-password-input.md) visibility toggle icon is now smaller.
* [PhoneInput](https://alpha.mantine.dev/llms/core-phone-input.md) without `defaultCountry` now displays a globe icon in the country button until a country is selected.
* Pills in [PillsInput](https://alpha.mantine.dev/llms/core-pills-input.md), `MultiSelect`, `TagsInput` and `TreeSelect` are larger and fill the input.
* [MultiSelect](https://alpha.mantine.dev/llms/core-multi-select.md#max-displayed-values) and [TagsInput](https://alpha.mantine.dev/llms/core-tags-input.md#max-displayed-values) now support `maxDisplayedValues` prop, and `wrapPills={false}` keeps their pills on one line.
* [Select](https://alpha.mantine.dev/llms/core-select.md#scrollable-dropdown) and other `Combobox`-based components now support `scrollBehavior="smooth"` for keyboard navigation.
* [DatePickerInput](https://alpha.mantine.dev/llms/dates-date-picker-input.md#multiple-dates) and the other picker inputs (month, year, week, quarter) with `type="multiple"` now support `valueDisplay="pills"` to render a removable pill per selected value.
* [DatesProvider](https://alpha.mantine.dev/llms/dates-getting-started.md#consistent-weeks) `consistentWeeks` is now `true` by default – every month has 6 weeks, set `consistentWeeks: false` to restore the previous behavior.

**Overlays and dropdowns**

* [Drawer](https://alpha.mantine.dev/llms/core-drawer.md#full-screen) now supports `fullScreen`. Use `fullScreenBelow` on `Modal` or `Drawer` to go full screen below a breakpoint.
* [Drawer](https://alpha.mantine.dev/llms/core-drawer.md#auto-size) now fits its content with `size="auto"`. Set [`withHandle`](https://alpha.mantine.dev/llms/core-drawer.md#drag-handle) to show a drag handle.
* Dropdowns nested inside a [Popover](https://alpha.mantine.dev/llms/core-popover.md#nested-popovers) can now keep their portals enabled without closing the outer popover.
* [Popover.ScrollArea](https://alpha.mantine.dev/llms/core-popover.md#scroll-area), `Menu.ScrollArea` and `Combobox.ScrollArea` make long dropdown content scrollable.
* [Tooltip](https://alpha.mantine.dev/llms/core-tooltip.md) now opens on keyboard focus, set `events={{ hover: true, focus: false, touch: false }}` to restore the previous behavior.
* Set `events={{ click: true }}` on [Tooltip](https://alpha.mantine.dev/llms/core-tooltip.md#click-to-toggle) to toggle it on click.
* [Spotlight](https://alpha.mantine.dev/llms/x-spotlight.md#virtualization) now supports virtualized actions lists: set `totalActionsCount` on `Spotlight.ActionsList` and `selected` on rendered `Spotlight.Action` components.

**Navigation and layout**

* [Breadcrumbs](https://alpha.mantine.dev/llms/core-breadcrumbs.md) and [Pagination](https://alpha.mantine.dev/llms/core-pagination.md) root elements are now `nav` landmarks.
* [NavLink](https://alpha.mantine.dev/llms/core-nav-link.md) with nested links and without `href` is now rendered as a `button` element.
* [Stepper.Step](https://alpha.mantine.dev/llms/core-stepper.md#wrapping-stepperstep) and [Timeline.Item](https://alpha.mantine.dev/llms/core-timeline.md#wrapping-timelineitem) can now be wrapped in other components.
* [Timeline.Item](https://alpha.mantine.dev/llms/core-timeline.md) now supports `active` and `lineActive` props.
* `Tree` now receives its store with the `store` prop, see the [migration guide](https://alpha.mantine.dev/llms/guides-9x-to-10x.md).
* The [Tree store](https://alpha.mantine.dev/llms/core-tree.md#scroll-to-node) now has `scrollTo` to expand a node's ancestors and scroll it into view. Use `getNodePath` to get its path.
* [Affix](https://alpha.mantine.dev/llms/core-affix.md) now supports `withSafeArea` prop to keep the content clear of the device notch.
* Set `withControls={false}` on [Scroller](https://alpha.mantine.dev/llms/core-scroller.md#without-controls) to hide its navigation buttons.

**Accessibility**

* [Combobox.Target](https://alpha.mantine.dev/llms/core-combobox.md) now sets `role="combobox"` and `aria-expanded`, set `withExpandedAttribute={false}` to restore the previous behavior.
* [LoadingOverlay](https://alpha.mantine.dev/llms/core-loading-overlay.md) now announces the loading state to screen readers, change the text with `loadingLabel` prop.
* [Pill](https://alpha.mantine.dev/llms/core-pill.md) remove button now has `aria-label="Remove"` by default.

**Hooks**

* [use-click-outside](https://alpha.mantine.dev/llms/hooks-use-click-outside.md#iframes) now detects clicks inside iframes, so `Popover`, `Menu` and `Combobox` dropdowns close when the user clicks an iframe.
* [useMatches](https://alpha.mantine.dev/llms/styles-responsive.md#use-matches-hook) now accepts custom breakpoints.
* [use-uncontrolled](https://alpha.mantine.dev/llms/hooks-use-uncontrolled.md) now returns the same setter across renders in both modes. It always calls the latest `onChange`.
* `writeLocalStorageValue` and `removeLocalStorageValue` update [useLocalStorage](https://alpha.mantine.dev/llms/hooks-use-local-storage.md#write-value-without-rerender) subscribers without rerendering the caller.

**Examples**

* New [Combobox examples](https://mantine.dev/combobox/MultiSelectSelectAll): select all in multiselect, category filter in the dropdown header, option details panel and mobile bottom sheet.
* New [form examples](https://mantine.dev/form/examples/LoginForm) show complete forms built with `useForm`.
