Chips

Alternative to Select and RadioGroup
Import

Usage

Color
Variant
Spacing
xs
sm
md
lg
xl
Size
xs
sm
md
lg
xl
Radius
xs
sm
md
lg
xl
import { Chips, Chip } from '@mantine/core';
function Demo() {
return (
<Chips>
<Chip value="react">React</Chip>
<Chip value="ng">Angular</Chip>
<Chip value="svelte">Svelte</Chip>
<Chip value="vue">Vue</Chip>
</Chips>
);
}

States

Multiple

Set multiple prop to enable multiple chips selection:

// Single chip can be selected at a time (radio input)
<Chips>{/* <Chip /> components */}</Chips>
// Multiple chips can be selected at a time (checkbox input)
<Chips multiple>{/* <Chip /> components */}</Chips>

Controlled

Since Chips component supports both single and multiple state you will need to adjust your state to match multiple prop:

import { useState } from 'react';
import { Chips, Chip } from '@mantine/core';
function Single() {
// string value when multiple is false (default)
const [value, setValue] = useState('react');
return (
<Chips multiple={false} value={value} onChange={setValue}>
<Chip value="react">React</Chip>
<Chip value="ng">Angular</Chip>
<Chip value="svelte">Svelte</Chip>
<Chip value="vue">Vue</Chip>
</Chips>
);
}
function Multiple() {
// array of strings value when multiple is true
const [value, setValue] = useState(['react']);
return (
<Chips value={value} onChange={setValue} multiple>
<Chip value="react">React</Chip>
<Chip value="ng">Angular</Chip>
<Chip value="svelte">Svelte</Chip>
<Chip value="vue">Vue</Chip>
</Chips>
);
}

Chip component

You can use Chip component outside of Chips context:

import { useState } from 'react';
import { Chip } from '@mantine/core';
function Demo() {
const [checked, setChecked] = useState(false);
return (
<Chip value="chip" checked={checked} onChange={setChecked}>
Just a chip
</Chip>
);
}

Change styles with Styles API

Chip and Chips components use the same Styles API schema, you can use classNames and styles listed under Styles API tab in both components:

import { createStyles, Chip, Chips } from '@mantine/core';
const useStyles = createStyles((theme, _params, getRef) => ({
iconWrapper: {
ref: getRef('iconWrapper'),
},
checked: {
backgroundColor: `${theme.colors.blue[6]} !important`,
color: theme.white,
[`& .${getRef('iconWrapper')}`]: {
color: theme.white,
},
},
}));
function Demo() {
const { classes } = useStyles();
return (
<Chips position="center" multiple classNames={classes} defaultValue={['react']}>
<Chip value="react">React</Chip>
<Chip value="ng">Angular</Chip>
<Chip value="vue">Vue</Chip>
<Chip value="svelte">Svelte</Chip>
</Chips>
);
}

Accessibility

Chip and Chips components are accessible by default since they are built with native radio/checkbox inputs, all keyboard events work the same as with native controls.