Chip API
导入
import Chip from '@mui/material/Chip';
// 或
import { Chip } from '@mui/material';
Chips represent complex entities in small blocks, such as a contact.
组件名称
在主题中,名称“MuiChip
”可用于提供默认属性(props),或者样式覆盖属性
原生(Native) 组件的属性也是可用的。
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
avatar | element | The Avatar for the Card Header. | |
children | unsupportedProp | This prop isn't supported. Use the component prop if you need to change the children structure. | |
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
clickable | bool | false | 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 both default and custom theme colors, which can be added as shown in the palette customization guide. |
component | elementType | The component used for the root node. Either a string to use a HTML element or a component. | |
deleteIcon | element | Override the default delete icon element. Shown only if onDelete is set. | |
disabled | bool | false | 如果被设置为 true ,那么该组件将会被禁用。 |
icon | element | Icon element. | |
label | node | The content of the component. | |
onDelete | func | 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. |
skipFocusWhenDisabled | bool | false | |
sx | Array<func | object | bool> | 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
规则名称 | 全局类名 | 描述 |
---|---|---|
root | .MuiChip-root | Styles applied to the root element. |
sizeSmall | .MuiChip-sizeSmall | Styles applied to the root element if size="small" . |
sizeMedium | .MuiChip-sizeMedium | Styles applied to the root element if size="medium" . |
colorError | .MuiChip-colorError | |
colorInfo | .MuiChip-colorInfo | |
colorPrimary | .MuiChip-colorPrimary | Styles applied to the root element if color="primary" . |
colorSecondary | .MuiChip-colorSecondary | Styles applied to the root element if color="secondary" . |
colorSuccess | .MuiChip-colorSuccess | |
colorWarning | .MuiChip-colorWarning | |
disabled | .Mui-disabled | Pseudo-class applied to the root element if disabled={true} . |
clickable | .MuiChip-clickable | Styles applied to the root element if onClick is defined or clickable={true} . |
clickableColorPrimary | .MuiChip-clickableColorPrimary | Styles applied to the root element if onClick and color="primary" is defined or clickable={true} . |
clickableColorSecondary | .MuiChip-clickableColorSecondary | Styles applied to the root element if onClick and color="secondary" is defined or clickable={true} . |
deletable | .MuiChip-deletable | Styles applied to the root element if onDelete is defined. |
deletableColorPrimary | .MuiChip-deletableColorPrimary | Styles applied to the root element if onDelete and color="primary" is defined. |
deletableColorSecondary | .MuiChip-deletableColorSecondary | Styles applied to the root element if onDelete and color="secondary" is defined. |
outlined | .MuiChip-outlined | Styles applied to the root element if variant="outlined" . |
filled | .MuiChip-filled | Styles applied to the root element if variant="filled" . |
outlinedPrimary | .MuiChip-outlinedPrimary | Styles applied to the root element if variant="outlined" and color="primary" . |
outlinedSecondary | .MuiChip-outlinedSecondary | Styles applied to the root element if variant="outlined" and color="secondary" . |
filledPrimary | .MuiChip-filledPrimary | Styles applied to the root element if variant="filled" and color="primary" . |
filledSecondary | .MuiChip-filledSecondary | Styles applied to the root element if variant="filled" and color="secondary" . |
avatar | .MuiChip-avatar | Styles applied to the avatar element. |
avatarSmall | .MuiChip-avatarSmall | Styles applied to the avatar element if size="small" . |
avatarMedium | .MuiChip-avatarMedium | Styles applied to the avatar element if size="medium" . |
avatarColorPrimary | .MuiChip-avatarColorPrimary | Styles applied to the avatar element if color="primary" . |
avatarColorSecondary | .MuiChip-avatarColorSecondary | Styles applied to the avatar element if color="secondary" . |
icon | .MuiChip-icon | Styles applied to the icon element. |
iconSmall | .MuiChip-iconSmall | Styles applied to the icon element if size="small" . |
iconMedium | .MuiChip-iconMedium | Styles applied to the icon element if size="medium" . |
iconColorPrimary | .MuiChip-iconColorPrimary | Styles applied to the icon element if color="primary" . |
iconColorSecondary | .MuiChip-iconColorSecondary | Styles applied to the icon element if color="secondary" . |
label | .MuiChip-label | Styles applied to the label `span` element. |
labelSmall | .MuiChip-labelSmall | Styles applied to the label `span` element if size="small" . |
labelMedium | .MuiChip-labelMedium | Styles applied to the label `span` element if size="medium" . |
deleteIcon | .MuiChip-deleteIcon | Styles applied to the deleteIcon element. |
deleteIconSmall | .MuiChip-deleteIconSmall | Styles applied to the deleteIcon element if size="small" . |
deleteIconMedium | .MuiChip-deleteIconMedium | Styles applied to the deleteIcon element if size="medium" . |
deleteIconColorPrimary | .MuiChip-deleteIconColorPrimary | Styles applied to the deleteIcon element if color="primary" and variant="filled" . |
deleteIconColorSecondary | .MuiChip-deleteIconColorSecondary | Styles applied to the deleteIcon element if color="secondary" and variant="filled" . |
deleteIconOutlinedColorPrimary | .MuiChip-deleteIconOutlinedColorPrimary | Styles applied to the deleteIcon element if color="primary" and variant="outlined" . |
deleteIconOutlinedColorSecondary | .MuiChip-deleteIconOutlinedColorSecondary | Styles applied to the deleteIcon element if color="secondary" and variant="outlined" . |
deleteIconFilledColorPrimary | .MuiChip-deleteIconFilledColorPrimary | Styles applied to the deleteIcon element if color="primary" and variant="filled" . |
deleteIconFilledColorSecondary | .MuiChip-deleteIconFilledColorSecondary | Styles applied to the deleteIcon element if color="secondary" and variant="filled" . |
focusVisible | .Mui-focusVisible | Pseudo-class applied to the root element if keyboard focused. |
您可以使用组件自定义选项对组件进行个性化:
- 具备 全局类名.
- 在自定义主体中,设定一个规则名称作为组件的
styleOverrides
属性的一部分。