UNPKG

2.85 kBTypeScriptView Raw
1import * as React from 'react';
2import { PropTypes } from '..';
3import { OverridableComponent, OverrideProps } from '../OverridableComponent';
4
5export interface ChipTypeMap<P = {}, D extends React.ElementType = 'div'> {
6 props: P & {
7 /**
8 * Avatar element.
9 */
10 avatar?: React.ReactElement;
11 /**
12 * This prop isn't supported.
13 * Use the `component` prop if you need to change the children structure.
14 */
15 children?: null;
16 /**
17 * If `true`, the chip will appear clickable, and will raise when pressed,
18 * even if the onClick prop is not defined.
19 * If false, the chip will not be clickable, even if onClick prop is defined.
20 * This can be used, for example,
21 * along with the component prop to indicate an anchor Chip is clickable.
22 */
23 clickable?: boolean;
24 /**
25 * The color of the component. It supports those theme colors that make sense for this component.
26 */
27 color?: Exclude<PropTypes.Color, 'inherit'>;
28 /**
29 * Override the default delete icon element. Shown only if `onDelete` is set.
30 */
31 deleteIcon?: React.ReactElement;
32 /**
33 * If `true`, the chip should be displayed in a disabled state.
34 */
35 disabled?: boolean;
36 /**
37 * Icon element.
38 */
39 icon?: React.ReactElement;
40 /**
41 * The content of the label.
42 */
43 label?: React.ReactNode;
44 /**
45 * Callback function fired when the delete icon is clicked.
46 * If set, the delete icon will be shown.
47 */
48 onDelete?: React.EventHandler<any>;
49 /**
50 * The size of the chip.
51 */
52 size?: 'small' | 'medium';
53 /**
54 * The variant to use.
55 */
56 variant?: 'default' | 'outlined';
57 };
58 defaultComponent: D;
59 classKey: ChipClassKey;
60}
61
62/**
63 * Chips represent complex entities in small blocks, such as a contact.
64 * Demos:
65 *
66 * - [Chips](https://mui.com/components/chips/)
67 *
68 * API:
69 *
70 * - [Chip API](https://mui.com/api/chip/)
71 */
72declare const Chip: OverridableComponent<ChipTypeMap>;
73
74export type ChipClassKey =
75 | 'root'
76 | 'sizeSmall'
77 | 'colorPrimary'
78 | 'colorSecondary'
79 | 'disabled'
80 | 'clickable'
81 | 'clickableColorPrimary'
82 | 'clickableColorSecondary'
83 | 'deletable'
84 | 'deletableColorPrimary'
85 | 'deletableColorSecondary'
86 | 'outlined'
87 | 'outlinedPrimary'
88 | 'outlinedSecondary'
89 | 'avatar'
90 | 'avatarSmall'
91 | 'avatarColorPrimary'
92 | 'avatarColorSecondary'
93 | 'icon'
94 | 'iconSmall'
95 | 'iconColorPrimary'
96 | 'iconColorSecondary'
97 | 'label'
98 | 'labelSmall'
99 | 'deleteIcon'
100 | 'deleteIconSmall'
101 | 'deleteIconColorPrimary'
102 | 'deleteIconColorSecondary'
103 | 'deleteIconOutlinedColorPrimary'
104 | 'deleteIconOutlinedColorSecondary';
105
106export type ChipProps<
107 D extends React.ElementType = ChipTypeMap['defaultComponent'],
108 P = {}
109> = OverrideProps<ChipTypeMap<P, D>, D>;
110
111export default Chip;