Stat

Display a key metric with a label, formatted value, trend and countdown

Usage

Stat displays a single key metric: a label, a formatted value and an optional trend indicator. Use it to build dashboard stat rows, KPI cards and summary blocks.

Active users
92,410
+12.4% increase
Size
Diff
import { Stat } from '@mantine/core';

function Demo() {
  return (
    <Stat
      label="Active users"
      value={92410}
      thousandSeparator diff={12.4}
    />
  );
}

Value formatting

Numeric values are formatted with NumberFormatter, Stat supports the same separator and decimal scale props. Use prefix and suffix to render units, currency or icons before and after the value:

Revenue
$1,340.50
Conversion
4.28%
Storage used
82/ 100 GB
import { Group, Stat } from '@mantine/core';

function Demo() {
  return (
    <Group gap={50}>
      <Stat
        label="Revenue"
        value={1340.5}
        prefix="$"
        decimalScale={2}
        fixedDecimalScale
        thousandSeparator
      />
      <Stat label="Conversion" value={4.28} suffix="%" />
      <Stat label="Storage used" value={82} suffix="/ 100 GB" />
    </Group>
  );
}

Numeric strings ('1234.5') are formatted the same way as numbers. Other strings ('12k', 'N/A') are rendered as is.

To fully control value rendering, pass a formatter function. It receives the raw value and returns any React node. Formatting props and animate are ignored when formatter is set:

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

function Demo() {
  return (
    <Stat
      label="Temperature"
      value={21.5}
      formatter={(value) => `${value} °C`}
    />
  );
}

Trend indicator

Set diff prop to display a trend delta below the value. Positive values are green with an up arrow, negative values are red with a down arrow, zero is dimmed. By default, the delta is rounded to at most one decimal and formatted as a signed percentage (+0.3%, -12%):

Revenue
92,410
+12.4% increase
Churn
1,240
-8.2% decrease
Stable
512
0% no change
import { Group, Stat } from '@mantine/core';

function Demo() {
  return (
    <Group gap={50}>
      <Stat label="Revenue" value={92410} thousandSeparator diff={12.4} />
      <Stat label="Churn" value={1240} thousandSeparator diff={-8.2} />
      <Stat label="Stable" value={512} diff={0} withDiffIcon={false} />
    </Group>
  );
}

Use diffFormatter to customize the delta text and withDiffIcon={false} to hide the arrow:

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

function Demo() {
  return (
    <Stat
      label="New customers"
      value={482}
      diff={38}
      diffFormatter={(diff) => `${diff > 0 ? '+' : ''}${diff} this week`}
    />
  );
}

Values and deltas are never truncated. In narrow containers, use responsive columns (for example, SimpleGrid with cols={{ base: 1, sm: 3 }}) instead of a fixed number of columns.

Icon

Use icon prop to display an icon next to the value:

Users
92,410
+12.4% increase
Revenue
$1,340.50
+4.1% increase
Downloads
18,320
import { CoinsIcon, DownloadSimpleIcon, UsersIcon } from '@phosphor-icons/react';
import { Group, Stat } from '@mantine/core';

function Demo() {
  return (
    <Group gap={50}>
      <Stat label="Users" value={92410} thousandSeparator diff={12.4} icon={<UsersIcon size={28} />} />
      <Stat
        label="Revenue"
        value={1340.5}
        prefix="$"
        decimalScale={2}
        fixedDecimalScale
        thousandSeparator
        diff={4.1}
        icon={<CoinsIcon size={28} />}
      />
      <Stat label="Downloads" value={18320} thousandSeparator icon={<DownloadSimpleIcon size={28} />} />
    </Group>
  );
}

Loading state

Set loading prop to display a Skeleton in place of the value. The trend indicator is hidden while loading is set:

Active users
Revenue
$
import { Group, Stat } from '@mantine/core';

function Demo() {
  return (
    <Group gap={50}>
      <Stat label="Active users" value={92410} thousandSeparator loading />
      <Stat
        label="Revenue"
        value={1340.5}
        prefix="$"
        decimalScale={2}
        fixedDecimalScale
        thousandSeparator
        loading
      />
    </Group>
  );
}

Animated value

Set the animate prop to animate value changes with RollingNumber. Animation only applies to numeric values:

Active users
import { useState } from 'react';
import { Button, Stack, Stat } from '@mantine/core';

function Demo() {
  const [value, setValue] = useState(92410);

  return (
    <Stack align="flex-start">
      <Stat label="Active users" value={value} thousandSeparator animate />
      <Button onClick={() => setValue(Math.round(Math.random() * 100000))}>
        Update value
      </Button>
    </Stack>
  );
}

Countdown

Stat.Countdown displays a live countdown to a target time. value is a Date or a timestamp in milliseconds. Keep it stable between renders (create it with useState or useMemo), a new value restarts the countdown.

Sale ends in
03:00:00
Launch in
1d 02:00:00
Round ends
00:59.999
import { useState } from 'react';
import { Group, Stat } from '@mantine/core';

function Demo() {
  const [targets] = useState(() => ({
    sale: Date.now() + 1000 * 60 * 60 * 3,
    launch: Date.now() + 1000 * 60 * 60 * 26,
    round: Date.now() + 1000 * 60,
  }));

  return (
    <Group gap={50}>
      <Stat.Countdown label="Sale ends in" value={targets.sale} />
      <Stat.Countdown label="Launch in" value={targets.launch} format="D[d] HH:mm:ss" />
      <Stat.Countdown label="Round ends" value={targets.round} format="mm:ss.SSS" />
    </Group>
  );
}

format prop accepts dayjs-style tokens (D, H, m, s, S):

  • Units absent from the format roll into the leading token: mm:ss displays 62 minutes as 62:00
  • S displays tenths of a second, SS hundredths and SSS milliseconds
  • Literal characters are escaped with square brackets, for example D[d] HH:mm:ss
  • The remaining time is rounded up: a 3 hour countdown starts at 03:00:00 and 00:00:00 is displayed only when it has finished

Stat.Countdown supports the same display props and Styles API selectors as Stat:

import { useState } from 'react';
import { Stat } from '@mantine/core';

function Demo() {
  const [target] = useState(() => Date.now() + 1000 * 60 * 15);

  return (
    <Stat.Countdown
      label="Offer expires in"
      value={target}
      format="mm:ss"
      onFinish={() => console.log('Countdown finished')}
      onTick={(remainingMs) => console.log(remainingMs)}
    />
  );
}

onFinish is called once when the target time is reached, and onTick is called on every tick with the remaining time in milliseconds.

Size

size prop scales the label, value, diff and icon. Change size in the configurator above to see how it scales.

Color

Set the color prop to change the value color. It accepts a value from theme.colors or any valid CSS color:

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

function Demo() {
  return <Stat label="Active users" value={92410} thousandSeparator color="blue" />;
}

Compound components

For full control over the layout, use compound components instead of the shorthand props:

$1,340.50
Total revenue
+12.4% increase
import { Stat } from '@mantine/core';

function Demo() {
  return (
    <Stat>
      <Stat.Value prefix="$">1,340.50</Stat.Value>
      <Stat.Label>Total revenue</Stat.Label>
      <Stat.Diff value={12.4} />
    </Stat>
  );
}
  • Stat.Icon – icon wrapper, always placed next to the value. Other components are rendered in the order they are declared.
  • Stat.Label – caption displayed above the value
  • Stat.Value – value wrapper, accepts prefix and suffix props
  • Stat.Diff – trend delta, accepts value, formatter, withIcon and labels props (or custom children)

Example: dashboard stat row

Compose multiple Stat components in a SimpleGrid or Group to build a stat row:

Active users
92,410
+12.4% increase
Revenue
$1,340.50
-4.1% decrease
Orders
2,847
+0.8% increase
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>
  );
}

Accessibility

  • Stat.Countdown value is not announced on every tick. To announce milestones (for example "5 minutes left"), render your own live region and update it from onTick.
  • When loading is set, the root element has aria-busy="true".
  • Stat.Diff renders a visually hidden direction text after the delta ("increase", "decrease" or "no change"), screen readers announce +12.4% increase. Use diffLabels on Stat or labels on Stat.Diff to translate these texts:
import { Stat } from '@mantine/core';

function Demo() {
  return (
    <Stat
      label="Chiffre d'affaires"
      value={1340}
      diff={12.4}
      diffLabels={{ increase: 'hausse', decrease: 'baisse', neutral: 'stable' }}
    />
  );
}

Styles API

Stat supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.

Active users
$92,410
+12.4% increase

Component Styles API

Hover over selectors to highlight corresponding elements

/*
 * Hover over selectors to apply outline styles
 *
 */