UNPKG

1.83 kBTypeScriptView Raw
1import * as React from 'react';
2import { StandardProps } from '..';
3import { IconButtonProps } from '../IconButton';
4
5export interface SwitchBaseProps
6 extends StandardProps<
7 IconButtonProps,
8 SwitchBaseClassKey,
9 'children' | 'onChange' | 'type' | 'value'
10 > {
11 autoFocus?: boolean;
12 /**
13 * If `true`, the component is checked.
14 */
15 checked?: boolean;
16 checkedIcon: React.ReactNode;
17 defaultChecked?: boolean;
18 disabled?: boolean;
19 /**
20 * If `true`, the ripple effect will be disabled.
21 */
22 disableRipple?: boolean;
23 icon: React.ReactNode;
24 /**
25 * The id of the `input` element.
26 */
27 id?: string;
28 /**
29 * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
30 */
31 inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
32 /**
33 * Pass a ref to the `input` element.
34 */
35 inputRef?: React.Ref<any>;
36 /**
37 * Name attribute of the `input` element.
38 */
39 name?: string;
40 /**
41 * Callback fired when the state is changed.
42 *
43 * @param {object} event The event source of the callback.
44 * You can pull out the new value by accessing `event.target.value` (string).
45 * You can pull out the new checked state by accessing `event.target.checked` (boolean).
46 */
47 onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
48 readOnly?: boolean;
49 /**
50 * If `true`, the `input` element will be required.
51 */
52 required?: boolean;
53 tabIndex?: number;
54 type?: React.InputHTMLAttributes<HTMLInputElement>['type'];
55 /**
56 * The value of the component. The DOM API casts this to a string.
57 */
58 value?: unknown;
59}
60
61export type SwitchBaseClassKey = 'root' | 'checked' | 'disabled' | 'input';
62
63declare const SwitchBase: React.ComponentType<SwitchBaseProps>;
64
65export default SwitchBase;