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
<Chips>
<Chip value="react">React</Chip>
<Chip value="ng">Angular</Chip>
<Chip value="svelte">Svelte</Chip>
<Chip value="vue">Vue</Chip>
</Chips>

States

<Chips multiple value={['checked', 'checked-disabled']}>
<Chip value="default">Default</Chip>
<Chip value="checked">Checked</Chip>
<Chip value="checked-disabled" disabled>
Checked disabled
</Chip>
</Chips>

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 } from '@mantine/core';
function Demo() {
// string value when multiple is false (default)
const [value, setValue] = useState('react');
return (
<Chips 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 Demo() {
// 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) => {
const iconWrapper = getRef('iconWrapper');
return {
iconWrapper: {
ref: iconWrapper,
},
checked: {
backgroundColor: `${theme.colors.blue[6]} !important`,
color: theme.white,
[`& .${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.

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