UNPKG

2.54 kBTypeScriptView Raw
1import * as React from 'react';
2import { InternalStandardProps as StandardProps } from '..';
3import { ButtonBaseProps } from '../ButtonBase';
4import { SwitchBaseClasses } from './switchBaseClasses';
5
6export interface SwitchBaseProps
7 extends StandardProps<ButtonBaseProps, 'children' | 'onChange' | 'type' | 'value'> {
8 autoFocus?: boolean;
9 /**
10 * If `true`, the component is checked.
11 */
12 checked?: boolean;
13 checkedIcon: React.ReactNode;
14 /**
15 * Override or extend the styles applied to the component.
16 */
17 classes?: Partial<SwitchBaseClasses>;
18 /**
19 * The default checked state. Use when the component is not controlled.
20 */
21 defaultChecked?: boolean;
22 /**
23 * If `true`, the component is disabled.
24 */
25 disabled?: boolean;
26 /**
27 * If `true`, the ripple effect is disabled.
28 * @default false
29 */
30 disableRipple?: boolean;
31 /**
32 * If `true`, the keyboard focus ripple is disabled.
33 * @default false
34 */
35 disableFocusRipple?: boolean;
36 /**
37 * If given, uses a negative margin to counteract the padding on one
38 * side (this is often helpful for aligning the left or right
39 * side of the icon with content above or below, without ruining the border
40 * size and shape).
41 * @default false
42 */
43 edge?: 'start' | 'end' | false;
44 icon: React.ReactNode;
45 /**
46 * The id of the `input` element.
47 */
48 id?: string;
49 /**
50 * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
51 */
52 inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
53 /**
54 * Pass a ref to the `input` element.
55 */
56 inputRef?: React.Ref<any>;
57 /**
58 * Name attribute of the `input` element.
59 */
60 name?: string;
61 /**
62 * Callback fired when the state is changed.
63 *
64 * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
65 * You can pull out the new value by accessing `event.target.value` (string).
66 * You can pull out the new checked state by accessing `event.target.checked` (boolean).
67 */
68 onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
69 readOnly?: boolean;
70 /**
71 * If `true`, the `input` element is required.
72 * @default false
73 */
74 required?: boolean;
75 tabIndex?: number;
76 type?: React.InputHTMLAttributes<HTMLInputElement>['type'];
77 /**
78 * The value of the component. The DOM API casts this to a string.
79 */
80 value?: unknown;
81}
82
83declare const SwitchBase: React.JSXElementConstructor<SwitchBaseProps>;
84
85export default SwitchBase;