Chip
TheChip component displays a compact element that can represent an input, attribute, or action. Material UI's Chip component provides a consistent, accessible, and customizable way to display tags, labels, or interactive elements.
Chips are used to display small pieces of information, such as tags, filters, selections, or actions that can be clicked or deleted.
Variants
Material UI Chips come in two variants:
Filled (Default)
The default variant with a solid background:
Filled
Chip
Chip
jsx<Chip label="Filled" /><Chip label="Chip" color="primary" /><Chip label="Chip" color="secondary" />
Outlined
A variant with an outlined border:
Outlined
Chip
Chip
jsx<Chip label="Outlined" variant="outlined" /><Chip label="Chip" variant="outlined" color="primary" /><Chip label="Chip" variant="outlined" color="secondary" />
Sizes
Chips come in two sizes:
Small
Medium
Small
Medium
jsx<Chip label="Small" size="small" /><Chip label="Medium" size="medium" />
Colors
Chips support different color schemes:
Default
Primary
Secondary
Success
Error
Warning
Info
jsx<Chip label="Primary" color="primary" /><Chip label="Secondary" color="secondary" /><Chip label="Success" color="success" /><Chip label="Error" color="error" /><Chip label="Warning" color="warning" /><Chip label="Info" color="info" />
Deletable Chips
Chips can include a delete icon:
Deletable
Deletable
Deletable
jsx<Chip label="Deletable" onDelete={() => {}} />
Interactive Deletable Chips
Chip 1
Chip 2
Chip 3
jsxconst [chips, setChips] = useState(["Chip 1", "Chip 2", "Chip 3"]);const handleDelete = (chipToDelete) => {setChips((chips) => chips.filter((chip) => chip !== chipToDelete));};{chips.map((chip) => (<Chipkey={chip}label={chip}onDelete={() => handleDelete(chip)}/>))}
Clickable Chips
Chips can be made clickable:
Clickable
Clickable
Click me
jsx<Chip label="Clickable" onClick={() => {}} />
Icon Chips
Chips can include icons:
With Icon
With Icon
Deletable
jsx<Chip icon={<Face />} label="With Icon" /><Chipicon={<Face />}label="Deletable"onDelete={() => {}}/>
Avatar Chips
Chips can display avatars:
M
AvatarJD
Deletablejsx<Chip avatar={<Avatar>M</Avatar>} label="Avatar" /><Chipavatar={<Avatar alt="Natacha" src="/avatar.jpg" />}label="Avatar"variant="outlined"/>
Custom Delete Icon
You can customize the delete icon:
jsx<Chiplabel="Custom Delete"onDelete={() => {}}deleteIcon={<Check />}/>
Disabled Chips
Chips can be disabled:
Disabled
Disabled
Disabled
jsx<Chip label="Disabled" disabled /><Chip label="Disabled" disabled onDelete={() => {}} />
Common Props
The Chip component accepts various props to customize its appearance and behavior:
jsx<Chiplabel="Label" // string | ReactNodevariant="filled" // 'filled' | 'outlined'color="default" // 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning'size="medium" // 'small' | 'medium'icon={<Icon />} // ReactNodeavatar={<Avatar />} // ReactNodeonDelete={handleDelete} // function - makes chip deletableonClick={handleClick} // function - makes chip clickabledisabled={false} // booleandeleteIcon={<DeleteIcon />} // ReactNode - custom delete iconsx={{}} // object - custom styles/>
Accessibility
Material UI Chips are built with accessibility in mind:
- Keyboard navigation: Clickable and deletable chips are keyboard accessible
- ARIA attributes: Proper ARIA labels and roles for screen readers
- Focus indicators: Clear visual focus indicators
- Delete action: Delete action is properly announced to screen readers
- Color contrast: Meets WCAG guidelines for color contrast ratios
- Interactive elements: All interactive chips have proper event handlers
Best Practices
- Use chips for tags and labels - Chips work well for displaying tags, categories, or labels
- Keep labels concise - Short, clear labels work best in chips
- Provide delete functionality - Use deletable chips when users should be able to remove items
- Use appropriate colors - Choose colors that match your design system and convey meaning
- Consider clickable chips - Make chips clickable when they represent selectable options
- Use icons meaningfully - Icons can enhance understanding but shouldn't replace clear labels
- Group related chips - Display related chips together in a flex container
- Handle deletion gracefully - Provide clear feedback when chips are deleted
Examples
Filter Chips
jsxconst [filters, setFilters] = useState(["Active", "Featured"]);const handleDelete = (filterToDelete) => {setFilters((filters) => filters.filter((filter) => filter !== filterToDelete));};<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}>{filters.map((filter) => (<Chipkey={filter}label={filter}onDelete={() => handleDelete(filter)}color="primary"/>))}</Box>
Selectable Chips
jsxconst [selected, setSelected] = useState([]);const handleToggle = (value) => {setSelected((prev) =>prev.includes(value)? prev.filter((item) => item !== value): [...prev, value]);};const options = ["Option 1", "Option 2", "Option 3"];<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}>{options.map((option) => (<Chipkey={option}label={option}onClick={() => handleToggle(option)}color={selected.includes(option) ? "primary" : "default"}/>))}</Box>
User Tags
jsxconst users = [{ name: "John Doe", avatar: "JD" },{ name: "Jane Smith", avatar: "JS" },];<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}>{users.map((user) => (<Chipkey={user.name}avatar={<Avatar>{user.avatar}</Avatar>}label={user.name}onDelete={() => {}}/>))}</Box>
Status Chips
jsx<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap" }}><Chip label="Active" color="success" /><Chip label="Pending" color="warning" /><Chip label="Inactive" color="default" /><Chip label="Error" color="error" /></Box>