Stepper

Display content divided into a steps sequence
Import

Usage

Step 2 content: Verify email
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} breakpoint="sm">
<Stepper.Step label="Fist 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 position="center" mt="xl">
<Button variant="default" onClick={prevStep}>Back</Button>
<Button onClick={nextStep}>Next step</Button>
</Group>
</>
);
}

Allow step select

To disable step selection set allowStepSelect prop on Stepper.Step component. It can be used to prevent user from reaching next steps:

Step 2 content: Verify email
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} breakpoint="sm">
<Stepper.Step label="Fist step" description="Create an account" allowStepSelect={active > 0}>
Step 1 content: Create an account
</Stepper.Step>
<Stepper.Step label="Second step" description="Verify email" allowStepSelect={active > 1}>
Step 2 content: Verify email
</Stepper.Step>
<Stepper.Step label="Final step" description="Get full access" allowStepSelect={active > 2}>
Step 3 content: Get full access
</Stepper.Step>
<Stepper.Completed>
Completed, click back button to get to previous step
</Stepper.Completed>
</Stepper>
<Group position="center" mt="xl">
<Button variant="default" onClick={prevStep}>Back</Button>
<Button onClick={nextStep}>Next step</Button>
</Group>
</>
);
}

Color, radius and size

You can use any color from theme.colors, by default Stepper will use theme.primaryColor:

Color
Radius
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
<Stepper size="md" active={1}>
<Stepper.Step label="Step 1" description="Create an account" />
<Stepper.Step label="Step 2" description="Verify email" />
</Stepper>

Component size is controlled by two props: size and iconSize. size prop controls icon size, label and description font size. iconSize allows to overwrite icon size separately from other size values:

<Stepper iconSize={42} active={1}>
<Stepper.Step label="Step 1" description="Create an account" />
<Stepper.Step label="Step 2" description="Verify email" />
</Stepper>

With custom icons

You can replace step icon by setting icon prop on Step component. To change completed check icon set completedIcon on Stepper component. You can use any React node as icon: component, string, number:

import { UserCheck, MailOpened, ShieldCheck, CircleCheck } from 'tabler-icons-react';
import { Stepper } from '@mantine/core';
function Demo() {
const [active, setActive] = useState(1);
return (
<Stepper active={active} onStepClick={setActive} completedIcon={<CircleCheck />}>
<Stepper.Step icon={<UserCheck size={18} />} label="Step 1" description="Create an account" />
<Stepper.Step icon={<MailOpened size={18} />} label="Step 2" description="Verify email" />
<Stepper.Step icon={<ShieldCheck size={18} />} label="Step 3" description="Get full access" />
</Stepper>
);
}

You can use Stepper with icons only. Note that in this case you will have to set aria-label or title on Step component to make it accessible:

import { UserCheck, MailOpened, ShieldCheck } from 'tabler-icons-react';
import { Stepper } from '@mantine/core';
function Demo() {
const [active, setActive] = useState(0);
return (
<Stepper active={active} onStepClick={setActive}>
<Stepper.Step icon={<UserCheck size={18} />} />
<Stepper.Step icon={<MailOpened size={18} />} />
<Stepper.Step icon={<ShieldCheck size={18} />} />
</Stepper>
);
}

You can also change completed icon for each step, for example, to indicate error state:

<Stepper active={2}>
<Stepper.Step label="Step 1" description="Create an account" />
<Stepper.Step
label="Step 2"
description="Verify email"
color="red"
completedIcon={<CircleX />}
/>
<Stepper.Step label="Step 3" description="Get full access" />
</Stepper>

Vertical orientation

<Stepper orientation="vertical">
{/* ...children */}
</Stepper>

Responsive styles

To change orientation based on viewport size set breakpoint prop. In following example stepper will have horizontal orientation when viewport width is more than theme.breakpoints.md:

<Stepper breakpoint="md">{/* ...steps */}</Stepper>

You can configure breakpoints in MantineProvider or use number to set breakpoint in px:

<Stepper breakpoint={755}>{/* ...steps */}</Stepper>

Icon position

To change step icon and body arrangement set iconPosition to right, this option is most useful for RTL:

<Stepper iconPosition="right">
{/* ...children */}
</Stepper>

Loading state

To indicate loading state set loading prop on Step component, Loader will replace step icon. You can configure default loader in MantineProvider.

<Stepper active={1}>
<Stepper.Step label="Step 1" description="Create an account" />
<Stepper.Step label="Step 2" description="Verify email" loading />
<Stepper.Step label="Step 3" description="Get full access" />
</Stepper>

Customize with Styles API

You can change Stepper styles using Styles API

Get step ref

You can get refs of step button and stepper root element (div):

import { useRef } from 'react';
import { Stepper } from '@mantine/core';
function MyStepper() {
const firstStep = useRef();
const stepper = useRef();
return (
<Stepper ref={stepper}>
<Stepper.Step label="First step" ref={firstStep} />
<Stepper.Step label="Second step" />
</Stepper>
);
}

Accessibility

<Stepper.Step /> components render button element, set aria-label or title props to make component visible for screen readers in case you do not specify label or description:

<Stepper.Step /> // -> not ok, empty labels for screen reader
<Stepper.Step label="Step 1" description="Create an account" /> // -> ok
<Stepper.Step aria-label="Create an account" /> // -> ok
<Stepper.Step title="Create an account" /> // -> ok
Build fully functional accessible web applications faster than ever
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback