-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Expand file tree
/
Copy pathButton.d.ts
More file actions
161 lines (151 loc) · 5.31 KB
/
Copy pathButton.d.ts
File metadata and controls
161 lines (151 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import * as React from 'react';
import { DistributiveOmit, OverridableStringUnion } from '@mui/types';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase';
import { OverrideProps, OverridableComponent, OverridableTypeMap } from '../OverridableComponent';
import { ButtonClasses } from './buttonClasses';
export interface ButtonPropsVariantOverrides {}
export interface ButtonPropsColorOverrides {}
export interface ButtonPropsSizeOverrides {}
export interface ButtonOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<ButtonClasses> | undefined;
/**
* The color of the component.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'primary'
*/
color?:
| OverridableStringUnion<
'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning',
ButtonPropsColorOverrides
>
| undefined;
/**
* If `true`, the component is disabled.
* @default false
*/
disabled?: boolean | undefined;
/**
* If `true`, no elevation is used.
* @default false
*/
disableElevation?: boolean | undefined;
/**
* If `true`, the keyboard focus ripple is disabled.
* @default false
*/
disableFocusRipple?: boolean | undefined;
/**
* Element placed after the children.
*/
endIcon?: React.ReactNode;
/**
* If `true`, allows a disabled component to retain keyboard and programmatic focusability while preventing activation.
* Disabled links remain non-focusable.
* @default false
*/
focusableWhenDisabled?: boolean | undefined;
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth?: boolean | undefined;
/**
* The URL to link to when the button is clicked.
* If defined, an `a` element will be used as the root node.
*/
href?: string | undefined;
/**
* If `true`, the loading indicator is visible and the button is disabled.
* If `true | false`, the loading wrapper is always rendered before the children to prevent [Google Translation Crash](https://github.com/mui/material-ui/issues/27853).
* @default null
*/
loading?: boolean | null | undefined;
/**
* Element placed before the children if the button is in loading state.
* The node should contain an element with `role="progressbar"` with an accessible name.
* By default, it renders a `CircularProgress` that is labeled by the button itself.
* @default <CircularProgress color="inherit" size={16} />
*/
loadingIndicator?: React.ReactNode;
/**
* The loading indicator can be positioned on the start, end, or the center of the button.
* @default 'center'
*/
loadingPosition?: 'start' | 'end' | 'center' | undefined;
/**
* The size of the component.
* `small` is equivalent to the dense button styling.
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium' | 'large', ButtonPropsSizeOverrides> | undefined;
/**
* Element placed before the children.
*/
startIcon?: React.ReactNode;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The variant to use.
* @default 'text'
*/
variant?:
| OverridableStringUnion<'text' | 'outlined' | 'contained', ButtonPropsVariantOverrides>
| undefined;
}
export type ButtonTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'button',
> = ExtendButtonBaseTypeMap<{
props: AdditionalProps & ButtonOwnProps;
defaultComponent: RootComponent;
}>;
/**
* utility to create component types that inherit props from ButtonBase.
* This component has an additional overload if the `href` prop is set which
* can make extension quite tricky
*/
export interface ExtendButtonTypeMap<TypeMap extends OverridableTypeMap> {
props: TypeMap['props'] &
(TypeMap['props'] extends { classes?: Record<string, string> | undefined }
? DistributiveOmit<ButtonTypeMap['props'], 'classes'>
: ButtonTypeMap['props']);
defaultComponent: TypeMap['defaultComponent'];
}
export type ExtendButton<TypeMap extends OverridableTypeMap> = ((
props: { href: string } & OverrideProps<ExtendButtonBaseTypeMap<TypeMap>, 'a'>,
) => React.JSX.Element) &
OverridableComponent<ExtendButtonBaseTypeMap<TypeMap>>;
/**
*
* Demos:
*
* - [Button Group](https://mui.com/material-ui/react-button-group/)
* - [Button](https://mui.com/material-ui/react-button/)
* - [Menubar](https://mui.com/material-ui/react-menubar/)
* - [Number Field](https://mui.com/material-ui/react-number-field/)
*
* API:
*
* - [Button API](https://mui.com/material-ui/api/button/)
* - inherits [ButtonBase API](https://mui.com/material-ui/api/button-base/)
*/
declare const Button: ExtendButtonBase<ButtonTypeMap>;
export type ButtonProps<
RootComponent extends React.ElementType = ButtonTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<ButtonTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
export default Button;