跳转到内容

Chip API

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

Import

import Chip from '@material-ui/core/Chip';
// 或
import { Chip } from '@material-ui/core';
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.

属性

名称类型默认值描述
avatarelementThe Avatar for the Card Header.
childrenunsupportedPropThis prop isn't supported. Use the component prop if you need to change the children structure.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
clickableboolfalseIf 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 be 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.
color'default'
| 'primary'
| 'secondary'
'default'The color of the component. It supports those theme colors that make sense for this component.
componentelementTypeThe component used for the root node. Either a string to use a HTML element or a component.
deleteIconelementOverride the default delete icon element. Shown only if onDelete is set.
disabledboolfalse如果被设置为 true,那么该组件将会被禁用。
iconelementIcon element.
labelnodeThe content of the component.
onDeletefuncCallback fired when the delete icon is clicked. If set, the delete icon will be shown.
size'medium'
| 'small'
'medium'The size of the autocomplete.
variant'filled'
| 'outlined'
| string
'filled'The variant to use.

ref 则会被传递到根元素中。
Any other props supplied will be provided to the root element (native element).

CSS

Rule nameGlobal class描述
root.MuiChip-rootStyles applied to the root element.
sizeSmall.MuiChip-sizeSmallStyles applied to the root element if size="small".
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".
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".
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".
deleteIcon.MuiChip-deleteIconStyles applied to the deleteIcon element.
deleteIconSmall.MuiChip-deleteIconSmallStyles applied to the deleteIcon element if size="small".
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: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos