UNPKG

1.99 kBTypeScriptView Raw
1import * as React from 'react';
2import { OverridableComponent, OverrideProps } from '../OverridableComponent';
3
4export interface FormLabelTypeMap<P = {}, D extends React.ElementType = 'label'> {
5 props: P &
6 FormLabelBaseProps & {
7 /**
8 * The content of the component.
9 */
10 children?: React.ReactNode;
11 /**
12 * The color of the component. It supports those theme colors that make sense for this component.
13 */
14 color?: 'primary' | 'secondary';
15 /**
16 * If `true`, the label should be displayed in a disabled state.
17 */
18 disabled?: boolean;
19 /**
20 * If `true`, the label should be displayed in an error state.
21 */
22 error?: boolean;
23 /**
24 * If `true`, the label should use filled classes key.
25 */
26 filled?: boolean;
27 /**
28 * If `true`, the input of this label is focused (used by `FormGroup` components).
29 */
30 focused?: boolean;
31 /**
32 * If `true`, the label will indicate that the input is required.
33 */
34 required?: boolean;
35 };
36 defaultComponent: D;
37 classKey: FormLabelClassKey;
38}
39
40/**
41 *
42 * Demos:
43 *
44 * - [Checkboxes](https://material-ui.com/components/checkboxes/)
45 * - [Radio Buttons](https://material-ui.com/components/radio-buttons/)
46 * - [Switches](https://material-ui.com/components/switches/)
47 *
48 * API:
49 *
50 * - [FormLabel API](https://material-ui.com/api/form-label/)
51 */
52declare const FormLabel: OverridableComponent<FormLabelTypeMap>;
53
54export type FormLabelClassKey =
55 | 'root'
56 | 'colorSecondary'
57 | 'focused'
58 | 'disabled'
59 | 'error'
60 | 'filled'
61 | 'required'
62 | 'asterisk';
63
64export type FormLabelBaseProps = React.LabelHTMLAttributes<HTMLLabelElement>;
65
66export type FormLabelProps<
67 D extends React.ElementType = FormLabelTypeMap['defaultComponent'],
68 P = {}
69> = OverrideProps<FormLabelTypeMap<P, D>, D>;
70
71export default FormLabel;