forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Button.tsx
727 lines (686 loc) · 22.1 KB
/
Button.tsx
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import {
elementTypeAcceptingRef,
refType,
unstable_capitalize as capitalize,
unstable_useForkRef as useForkRef,
} from '@mui/utils';
import { useButton } from '@mui/base/ButtonUnstyled';
import { EventHandlers } from '@mui/base/utils';
import composeClasses from '@mui/base/composeClasses';
import { useThemeProps, alpha } from '@mui/system';
import TouchRipple from './TouchRipple';
import { TouchRippleActions } from './TouchRipple.types';
import useTouchRipple from './useTouchRipple';
import { MD3ColorSchemeTokens, styled } from '../styles';
import buttonClasses, { getButtonUtilityClass } from './buttonClasses';
import { ButtonProps, ExtendButton, ButtonTypeMap, ButtonOwnerState } from './Button.types';
const useUtilityClasses = (styleProps: ButtonOwnerState) => {
const {
classes,
color,
disabled,
disableElevation,
focusVisible,
focusVisibleClassName,
fullWidth,
size,
variant,
} = styleProps;
const slots = {
root: [
'root',
disabled && 'disabled',
focusVisible && 'focusVisible',
variant,
`color${capitalize(color ?? '')}`,
`size${capitalize(size ?? '')}`,
disableElevation && 'disableElevation',
fullWidth && 'fullWidth',
],
label: ['label'],
startIcon: ['startIcon', `iconSize${capitalize(size ?? '')}`],
endIcon: ['endIcon', `iconSize${capitalize(size ?? '')}`],
};
const composedClasses = composeClasses(slots, getButtonUtilityClass, classes);
if (focusVisible && focusVisibleClassName) {
composedClasses.root += ` ${focusVisibleClassName}`;
}
return composedClasses;
};
const commonIconStyles = ({ size }: ButtonOwnerState) => ({
color: 'var(--md-comp-button-icon-color)',
...(size === 'small' && {
'& > *:nth-of-type(1)': {
fontSize: 18,
},
}),
...(size === 'medium' && {
'& > *:nth-of-type(1)': {
fontSize: 20,
},
}),
...(size === 'large' && {
'& > *:nth-of-type(1)': {
fontSize: 22,
},
}),
});
export const ButtonRoot = styled('button', {
name: 'MuiButton',
slot: 'Root',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.root,
styles[ownerState.variant],
styles[`${ownerState.variant}${capitalize(ownerState.color)}`],
styles[`size${capitalize(ownerState.size)}`],
styles[`${ownerState.variant}Size${capitalize(ownerState.size)}`],
ownerState.color === 'inherit' && styles.colorInherit,
ownerState.disableElevation && styles.disableElevation,
ownerState.fullWidth && styles.fullWidth,
];
},
})<{ ownerState: ButtonOwnerState }>(({ ownerState, theme }) => {
const tokens = theme.vars || theme;
const containerColor = {
elevated: `linear-gradient(0deg, rgba(103, 80, 164, 0.05), rgba(103, 80, 164, 0.05)), ${tokens.sys.color.surface}`,
filled: tokens.sys.color[ownerState.color ?? 'primary'],
filledTonal: tokens.sys.color.secondaryContainer,
outlined: 'transparent',
text: 'transparent',
};
const labelTextColor = {
elevated: tokens.sys.color.primary,
filled:
tokens.sys.color[
`on${capitalize(ownerState.color ?? 'primary')}` as keyof MD3ColorSchemeTokens
],
filledTonal: tokens.sys.color.onSecondaryContainer,
outlined: tokens.sys.color[ownerState.color ?? 'primary'],
text: tokens.sys.color[ownerState.color ?? 'primary'],
};
const disabeldContainerColor = {
elevated: theme.vars
? `rgba(${theme.vars.sys.color.onSurfaceChannel} / 0.12)`
: alpha(theme.sys.color.onSurface, 0.12),
filled: theme.vars
? `rgba(${theme.vars.sys.color.onSurfaceChannel} / 0.12)`
: alpha(theme.sys.color.onSurface, 0.12),
filledTonal: theme.vars
? `rgba(${theme.vars.sys.color.onSurfaceChannel} / 0.12)`
: alpha(theme.sys.color.onSurface, 0.12),
outlined: 'transparent',
text: 'transparent',
};
const hoveredContainerColor = {
elevated: theme.vars
? `rgba(${tokens.sys.color.primaryChannel} / ${tokens.sys.state.hover.stateLayerOpacity})`
: alpha(theme.sys.color.primary, theme.sys.state.hover.stateLayerOpacity),
filled: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / calc(1 - ${
tokens.sys.state.hover.stateLayerOpacity
}))`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
1 - theme.sys.state.hover.stateLayerOpacity,
),
filledTonal: theme.vars
? `rgba(${tokens.sys.color.secondaryContainerChannel} / calc(1 - ${tokens.sys.state.hover.stateLayerOpacity}))`
: alpha(theme.sys.color.secondaryContainer, 1 - theme.sys.state.hover.stateLayerOpacity),
outlined: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.hover.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.hover.stateLayerOpacity,
),
text: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.hover.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.hover.stateLayerOpacity,
),
};
const pressedContainerColor = {
elevated: theme.vars
? `rgba(${tokens.sys.color.primaryChannel} / ${tokens.sys.state.pressed.stateLayerOpacity})`
: alpha(theme.sys.color.primary, theme.sys.state.pressed.stateLayerOpacity),
filled: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / calc(1 - ${
tokens.sys.state.pressed.stateLayerOpacity
}))`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
1 - theme.sys.state.pressed.stateLayerOpacity,
),
filledTonal: theme.vars
? `rgba(${tokens.sys.color.secondaryContainerChannel} / calc(1 - ${tokens.sys.state.pressed.stateLayerOpacity}))`
: alpha(theme.sys.color.secondaryContainer, 1 - theme.sys.state.pressed.stateLayerOpacity),
outlined: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.pressed.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.pressed.stateLayerOpacity,
),
text: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.pressed.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.pressed.stateLayerOpacity,
),
};
const focusedContainerColor = {
elevated: theme.vars
? `rgba(${tokens.sys.color.primaryChannel} / ${tokens.sys.state.focus.stateLayerOpacity})`
: alpha(theme.sys.color.primary, theme.sys.state.focus.stateLayerOpacity),
filled: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / calc(1 - ${
tokens.sys.state.focus.stateLayerOpacity
}))`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
1 - theme.sys.state.focus.stateLayerOpacity,
),
// According to the spec, this should be: secondaryContainerChannel / 1 - focusStateLayerOpacity, but this doesn't have the enough contrast
filledTonal: theme.vars
? `rgba(${tokens.sys.color.primaryChannel} / 0.3)`
: alpha(theme.sys.color.primary, 0.3),
outlined: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.focus.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.focus.stateLayerOpacity,
),
text: theme.vars
? `rgba(${tokens.sys.color[`${ownerState.color ?? 'primary'}Channel`]} / ${
tokens.sys.state.focus.stateLayerOpacity
})`
: alpha(
theme.sys.color[ownerState.color ?? 'primary'],
theme.sys.state.focus.stateLayerOpacity,
),
};
const containerElevation = {
elevated: tokens.sys.elevation[1],
filled: tokens.sys.elevation[0],
filledTonal: tokens.sys.elevation[0],
outlined: tokens.sys.elevation[0],
text: tokens.sys.elevation[0],
};
const hoveredContainerElevation = {
elevated: tokens.sys.elevation[2],
filled: tokens.sys.elevation[1],
filledTonal: tokens.sys.elevation[1],
outlined: tokens.sys.elevation[0],
text: tokens.sys.elevation[0],
};
const focusedContainerElevation = {
elevated: tokens.sys.elevation[1],
filled: tokens.sys.elevation[0],
filledTonal: tokens.sys.elevation[0],
outlined: tokens.sys.elevation[0],
text: tokens.sys.elevation[0],
};
const pressedContainerElevation = {
elevated: tokens.sys.elevation[1],
filled: tokens.sys.elevation[0],
filledTonal: tokens.sys.elevation[0],
outlined: tokens.sys.elevation[0],
text: tokens.sys.elevation[0],
};
const disabledLabelTextColor = theme.vars
? `rgba(${theme.vars.sys.color.onSurfaceChannel} / 0.38)`
: alpha(theme.sys.color.onSurface, 0.38);
const letterSpacing = `${
theme.sys.typescale.label.large.tracking / theme.sys.typescale.label.large.size
}rem`;
const borderRadiusValue: string | number = tokens.md3.shape.borderRadius;
const borderRadius = Number.isNaN(Number(borderRadiusValue))
? borderRadiusValue
: `${borderRadiusValue}px`;
return {
// Icon variables default values
'--md-comp-button-icon-color': labelTextColor[ownerState.variant ?? 'text'],
'--md-comp-button-hovered-icon-color': labelTextColor[ownerState.variant ?? 'text'], // same as default
'--md-comp-button-pressed-icon-color': labelTextColor[ownerState.variant ?? 'text'], // same as default
'--md-comp-button-focused-icon-color': labelTextColor[ownerState.variant ?? 'text'], // same as default
'--md-comp-button-disabled-icon-color': disabledLabelTextColor,
// Noramlized styles for buttons
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
boxSizing: 'border-box',
WebkitTapHighlightColor: 'transparent',
// We disable the focus ring for mouse, touch and keyboard users.
outline: 0,
border: 0,
margin: `var(--Button-margin, 0)`, // Remove the margin in Safari by default
cursor: 'pointer',
userSelect: 'none',
verticalAlign: 'middle',
MozAppearance: 'none', // Reset
WebkitAppearance: 'none', // Reset
textDecoration: 'none',
'&::-moz-focus-inner': {
borderStyle: 'none', // Remove Firefox dotted outline.
},
'@media print': {
colorAdjust: 'exact',
},
padding: '10px 24px',
minWidth: 64,
letterSpacing,
transition: theme.sys.motion.create(
['background-color', 'box-shadow', 'border-color', 'color'],
{
duration: tokens.sys.motion.duration.short3,
},
),
fontFamily: tokens.sys.typescale.label.large.family,
fontWeight: tokens.sys.typescale.label.large.weight,
fontSize: theme.typography.pxToRem(theme.sys.typescale.label.large.size), // the pxToRem should be moved to typescale in the future
lineHeight: `calc(${tokens.sys.typescale.label.large.lineHeight} / ${theme.sys.typescale.label.large.size})`,
borderRadius: `var(--Button-radius, ${borderRadius})`,
backgroundColor: containerColor[ownerState.variant ?? 'text'],
color: labelTextColor[ownerState.variant ?? 'text'],
boxShadow: containerElevation[ownerState.variant ?? 'text'],
// Outlined varaiant
...(ownerState.variant === 'outlined' && {
border: `1px solid ${tokens.sys.color.outline}`,
padding: '9px 23px',
}),
'--Button-gap': '0.5rem',
// Sizes are not specified in Material You, this need to be revised
...(ownerState.size === 'small' && {
'--Button-gap': '0.45rem',
fontSize: theme.typography.pxToRem(theme.sys.typescale.label.large.size - 1), // the pxToRem should be moved to typescale in the future
padding: '8px 20px',
...(ownerState.variant === 'outlined' && {
padding: '7px 19px',
}),
}),
...(ownerState.size === 'large' && {
'--Button-gap': '0.55rem',
fontSize: theme.typography.pxToRem(theme.sys.typescale.label.large.size + 1), // the pxToRem should be moved to typescale in the future
padding: '12px 26px',
...(ownerState.variant === 'outlined' && {
padding: '11px 25px',
}),
}),
'&:hover': {
'--md-comp-button-icon-color': 'var(--md-comp-button-hovered-icon-color)',
backgroundColor: hoveredContainerColor[ownerState.variant ?? 'text'],
boxShadow: hoveredContainerElevation[ownerState.variant ?? 'text'],
},
'&:active': {
'--md-comp-button-icon-color': 'var(--md-comp-button-pressed-icon-color)',
...((ownerState.disableRipple || ownerState.disableTouchRipple) && {
backgroundColor: pressedContainerColor[ownerState.variant ?? 'text'],
}),
boxShadow: pressedContainerElevation[ownerState.variant ?? 'text'],
},
[`&.${buttonClasses.focusVisible}`]: {
'--md-comp-button-icon-color': 'var(--md-comp-button-focused-icon-color)',
backgroundColor: focusedContainerColor[ownerState.variant ?? 'text'],
boxShadow: focusedContainerElevation[ownerState.variant ?? 'text'],
},
[`&.${buttonClasses.disabled}`]: {
// Allows deverloper to specify the disabled icon color var
'--md-comp-button-icon-color': 'var(--md-comp-button-disabled-icon-color)',
pointerEvents: 'none', // Disable link interactions
cursor: 'default',
color: disabledLabelTextColor,
backgroundColor: disabeldContainerColor[ownerState.variant ?? 'text'],
boxShadow: tokens.sys.elevation[0],
...(ownerState.variant === 'outlined' && {
border: `1px solid ${
theme.vars
? `rgba(${theme.vars.sys.color.onSurfaceChannel} / 0.12)`
: alpha(theme.sys.color.onSurface, 0.12)
}`,
}),
},
};
});
const ButtonStartIcon = styled('span', {
name: 'MuiButton',
slot: 'StartIcon',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [styles.startIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
},
})<{ ownerState: ButtonOwnerState }>(({ ownerState }) => ({
display: 'inherit',
marginRight: 'var(--Button-gap)',
...commonIconStyles(ownerState),
}));
const ButtonEndIcon = styled('span', {
name: 'MuiButton',
slot: 'EndIcon',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [styles.endIcon, styles[`iconSize${capitalize(ownerState.size)}`]];
},
})<{ ownerState: ButtonOwnerState }>(({ ownerState }) => ({
display: 'inherit',
marginLeft: 'var(--Button-gap)',
...commonIconStyles(ownerState),
}));
const Button = React.forwardRef(function Button<
BaseComponentType extends React.ElementType = ButtonTypeMap['defaultComponent'],
>(inProps: ButtonProps<BaseComponentType>, ref: React.ForwardedRef<any>) {
const props = useThemeProps({ props: inProps, name: 'MuiButton' });
const {
action,
centerRipple = false,
children,
className,
color = 'primary',
component = 'button',
disabled = false,
focusableWhenDisabled = false,
disableElevation = false,
disableRipple = false,
disableTouchRipple = false,
endIcon: endIconProp,
focusVisibleClassName,
fullWidth = false,
LinkComponent = 'a',
onBlur,
onClick,
onContextMenu,
onDragLeave,
onFocus,
onFocusVisible,
onKeyDown,
onKeyUp,
onMouseDown,
onMouseLeave,
onMouseUp,
onTouchEnd,
onTouchMove,
onTouchStart,
size = 'medium',
startIcon: startIconProp,
tabIndex = 0,
TouchRippleProps,
type,
variant = 'text',
...other
} = props;
const buttonRef = React.useRef<HTMLButtonElement | HTMLAnchorElement | HTMLElement>(null);
const handleRef = useForkRef(buttonRef, ref);
const rippleRef = React.useRef<TouchRippleActions>(null);
let ComponentProp = component;
if (ComponentProp === 'button' && (other.href || other.to)) {
ComponentProp = LinkComponent;
}
const { focusVisible, setFocusVisible, getRootProps } = useButton({
disabled,
focusableWhenDisabled,
href: props.href,
onFocusVisible,
tabIndex,
// @ts-ignore
to: props.to,
type,
ref: handleRef,
});
React.useImperativeHandle(
action,
() => ({
focusVisible: () => {
setFocusVisible(true);
buttonRef.current!.focus();
},
}),
[setFocusVisible],
);
const { enableTouchRipple, getRippleHandlers } = useTouchRipple({
disabled,
disableRipple,
disableTouchRipple,
rippleRef,
});
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (enableTouchRipple && !rippleRef.current) {
console.error(
[
'MUI: The `component` prop provided to Button is invalid.',
'Please make sure the children prop is rendered in this custom component.',
].join('\n'),
);
}
}, [enableTouchRipple]);
}
const ownerState = {
...props,
color,
component,
disabled,
disableElevation,
focusVisible,
fullWidth,
size,
tabIndex,
type,
variant,
};
const classes = useUtilityClasses(ownerState);
const startIcon = startIconProp && (
<ButtonStartIcon className={classes.startIcon} ownerState={ownerState}>
{startIconProp}
</ButtonStartIcon>
);
const endIcon = endIconProp && (
<ButtonEndIcon className={classes.endIcon} ownerState={ownerState}>
{endIconProp}
</ButtonEndIcon>
);
return (
<ButtonRoot
as={ComponentProp}
className={clsx(classes.root, className)}
ownerState={ownerState}
{...getRootProps(getRippleHandlers(props) as unknown as EventHandlers)}
{...other}
>
{startIcon}
{children}
{endIcon}
{enableTouchRipple ? (
/* TouchRipple is only needed client-side, x2 boost on the server. */
<TouchRipple center={centerRipple} {...TouchRippleProps} ref={rippleRef} />
) : null}
</ButtonRoot>
);
}) as ExtendButton<ButtonTypeMap>;
Button.propTypes /* remove-proptypes */ = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit TypeScript types and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* A ref for imperative actions.
* It currently only supports `focusVisible()` action.
*/
action: refType,
/**
* If `true`, the ripples are centered.
* They won't start at the cursor interaction position.
* @default false
*/
centerRipple: PropTypes.bool,
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* 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/#adding-new-colors).
* @default 'primary'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['primary', 'secondary', 'tertiary']),
PropTypes.string,
]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: elementTypeAcceptingRef,
/**
* If `true`, the component is disabled.
* @default false
*/
disabled: PropTypes.bool,
/**
* If `true`, no elevation is used.
* @default false
*/
disableElevation: PropTypes.bool,
/**
* If `true`, the ripple effect is disabled.
* @default false
*/
disableRipple: PropTypes.bool,
/**
* If `true`, the touch ripple effect is disabled.
* @default false
*/
disableTouchRipple: PropTypes.bool,
/**
* Element placed after the children.
*/
endIcon: PropTypes.node,
/**
* @ignore
*/
focusVisibleClassName: PropTypes.string,
/**
* If `true`, the button will take up the full width of its container.
* @default false
*/
fullWidth: PropTypes.bool,
/**
* The URL to link to when the button is clicked.
* If defined, an `a` element will be used as the root node.
*/
href: PropTypes.string,
/**
* The component used to render a link when the `href` prop is provided.
* @default 'a'
*/
LinkComponent: PropTypes.elementType,
/**
* @ignore
*/
onBlur: PropTypes.func,
/**
* @ignore
*/
onClick: PropTypes.func,
/**
* @ignore
*/
onContextMenu: PropTypes.func,
/**
* @ignore
*/
onDragLeave: PropTypes.func,
/**
* @ignore
*/
onFocus: PropTypes.func,
/**
* @ignore
*/
onFocusVisible: PropTypes.func,
/**
* @ignore
*/
onKeyDown: PropTypes.func,
/**
* @ignore
*/
onKeyUp: PropTypes.func,
/**
* @ignore
*/
onMouseDown: PropTypes.func,
/**
* @ignore
*/
onMouseLeave: PropTypes.func,
/**
* @ignore
*/
onMouseUp: PropTypes.func,
/**
* @ignore
*/
onTouchEnd: PropTypes.func,
/**
* @ignore
*/
onTouchMove: PropTypes.func,
/**
* @ignore
*/
onTouchStart: PropTypes.func,
/**
* The size of the component.
* `small` is equivalent to the dense button styling.
* @default 'medium'
*/
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['small', 'medium', 'large']),
PropTypes.string,
]),
/**
* Element placed before the children.
*/
startIcon: PropTypes.node,
/**
* @default 0
*/
tabIndex: PropTypes.number,
/**
* Props applied to the `TouchRipple` element.
*/
TouchRippleProps: PropTypes.object,
/**
* @ignore
*/
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
/**
* The variant to use.
* @default 'text'
*/
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['text', 'outlined', 'filled', 'filledTonal', 'elevated']),
PropTypes.string,
]),
} as any;
export default Button;