跳转到内容

Chip API

API documentation for the React Chip component. Learn about the available props, and the CSS API.

Import

import Chip from '@mui/material/Chip';
// 或
import { Chip } from '@mui/material';
You can learn about the difference by reading this guide on minimizing bundle size.

Chips represent complex entities in small blocks, such as a contact.

Component name

The name MuiChip can be used when providing default props or style overrides in the theme.

属性

Props of the 原生(Native) component are also available.

名称类型默认值描述
avatarelement
The Avatar for the Card Header.
childrenunsupportedProp
This prop isn't supported. Use the component prop if you need to change the children structure.
classesobject
Override or extend the styles applied to the component. See CSS API below for more details.
clickableboolfalse
If true, the chip will appear clickable, and will raise when pressed, even if the onClick prop is not defined. If false, the chip will not appear clickable, even if onClick prop is defined. This can be used, for example, along with the component prop to indicate an anchor Chip is clickable. Note: this controls the UI and does not affect the onClick event.
color'default'
| 'primary'
| 'secondary'
| 'error'
| 'info'
| 'success'
| 'warning'
| string
'default'
The color of the component. It supports those theme colors that make sense for this component.
componentelementType
The component used for the root node. Either a string to use a HTML element or a component.
deleteIconelement
Override the default delete icon element. Shown only if onDelete is set.
disabledboolfalse
如果被设置为 true,那么该组件将会被禁用。
iconelement
Icon element.
labelnode
The content of the component.
onDeletefunc
Callback fired when the delete icon is clicked. If set, the delete icon will be shown.
size'medium'
| 'small'
| string
'medium'
The size of the autocomplete.
sxArray<func
| object>
| func
| object
The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.
variant'filled'
| 'outlined'
| string
'filled'
The variant to use.

ref 则会被传递到根元素中。

CSS

Rule nameGlobal class描述
root.MuiChip-rootStyles applied to the root element.
sizeSmall.MuiChip-sizeSmallStyles applied to the root element if size="small".
sizeMedium.MuiChip-sizeMediumStyles applied to the root element if size="medium".
colorPrimary.MuiChip-colorPrimaryStyles applied to the root element if color="primary".
colorSecondary.MuiChip-colorSecondaryStyles applied to the root element if color="secondary".
disabled.Mui-disabledPseudo-class applied to the root element if disabled={true}.
clickable.MuiChip-clickableStyles applied to the root element if onClick is defined or clickable={true}.
clickableColorPrimary.MuiChip-clickableColorPrimaryStyles applied to the root element if onClick and color="primary" is defined or clickable={true}.
clickableColorSecondary.MuiChip-clickableColorSecondaryStyles applied to the root element if onClick and color="secondary" is defined or clickable={true}.
deletable.MuiChip-deletableStyles applied to the root element if onDelete is defined.
deletableColorPrimary.MuiChip-deletableColorPrimaryStyles applied to the root element if onDelete and color="primary" is defined.
deletableColorSecondary.MuiChip-deletableColorSecondaryStyles applied to the root element if onDelete and color="secondary" is defined.
outlined.MuiChip-outlinedStyles applied to the root element if variant="outlined".
filled.MuiChip-filledStyles applied to the root element if variant="filled".
outlinedPrimary.MuiChip-outlinedPrimaryStyles applied to the root element if variant="outlined" and color="primary".
outlinedSecondary.MuiChip-outlinedSecondaryStyles applied to the root element if variant="outlined" and color="secondary".
avatar.MuiChip-avatarStyles applied to the avatar element.
avatarSmall.MuiChip-avatarSmallStyles applied to the avatar element if size="small".
avatarMedium.MuiChip-avatarMediumStyles applied to the avatar element if size="medium".
avatarColorPrimary.MuiChip-avatarColorPrimaryStyles applied to the avatar element if color="primary".
avatarColorSecondary.MuiChip-avatarColorSecondaryStyles applied to the avatar element if color="secondary".
icon.MuiChip-iconStyles applied to the icon element.
iconSmall.MuiChip-iconSmallStyles applied to the icon element if size="small".
iconMedium.MuiChip-iconMediumStyles applied to the icon element if size="medium".
iconColorPrimary.MuiChip-iconColorPrimaryStyles applied to the icon element if color="primary".
iconColorSecondary.MuiChip-iconColorSecondaryStyles applied to the icon element if color="secondary".
label.MuiChip-labelStyles applied to the label `span` element.
labelSmall.MuiChip-labelSmallStyles applied to the label `span` element if size="small".
labelMedium.MuiChip-labelMediumStyles applied to the label `span` element if size="medium".
deleteIcon.MuiChip-deleteIconStyles applied to the deleteIcon element.
deleteIconSmall.MuiChip-deleteIconSmallStyles applied to the deleteIcon element if size="small".
deleteIconMedium.MuiChip-deleteIconMediumStyles applied to the deleteIcon element if size="medium".
deleteIconColorPrimary.MuiChip-deleteIconColorPrimaryStyles applied to the deleteIcon element if color="primary" and variant="filled".
deleteIconColorSecondary.MuiChip-deleteIconColorSecondaryStyles applied to the deleteIcon element if color="secondary" and variant="filled".
deleteIconOutlinedColorPrimary.MuiChip-deleteIconOutlinedColorPrimaryStyles applied to the deleteIcon element if color="primary" and variant="outlined".
deleteIconOutlinedColorSecondary.MuiChip-deleteIconOutlinedColorSecondaryStyles applied to the deleteIcon element if color="secondary" and variant="outlined".
focusVisible.Mui-focusVisiblePseudo-class applied to the root element if keyboard focused.

You can override the style of the component using one of these customization options:

Demos