Skip to main content

Chips

Example

import { useState } from 'react';
import Chip from '@mavvy/m3-ui/Chip';

function Example() {
const [selected, setSelected] = useState(false);

const handleSelect = () => {
setSelected((v) => !v);
}
return (
<div>
<Chip onClick={handleSelect} selected={selected}>
Hello
</Chip>
<Chip color="primary" onClick={handleSelect} selected={selected}>
Hello
</Chip>
<Chip leadingIcon="check" onClick={handleSelect} selected={selected}>
Hello
</Chip>
<Chip
leadingIcon="check"
color="primary"
onClick={handleSelect}
selected={selected}
>
Hello
</Chip>
<Chip
trailingIcon="close"
color="primary"
onClick={handleSelect}
selected={selected}
>
Hello
</Chip>
</div>
);
}

Preview

Hello
Hello
checkHello
checkHello
Helloclose

Props

proptypedescription
colorColorcomponent color
leadingIconstringleading icon to render on the chip
leadingIconClassNamestringclassName to apply on the leadingIcon Icon component
trailingIconstringtrailing icon to render on the chip
trailingIconClassNamestringclassName to apply on the trailingIcon Icon component
classNamestringclassName of the chip component
textClassNamestringclassName of the Text component
selectedbooleanif tru, shows a selected state
onClick(event: React.MouseEvent) => voidhandler for the click event
variantfilled|outlinedvariant of the Chip component
sizeSizesize of the chip component