UNPKG

2.15 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { OverridableStringUnion } from '@mui/types';
4import { InternalStandardProps as StandardProps, Theme } from '..';
5import { SwitchBaseProps } from '../internal/SwitchBase';
6import { SwitchClasses } from './switchClasses';
7
8export interface SwitchPropsSizeOverrides {}
9
10export interface SwitchPropsColorOverrides {}
11
12export interface SwitchProps
13 extends StandardProps<SwitchBaseProps, 'checkedIcon' | 'color' | 'icon'> {
14 /**
15 * The icon to display when the component is checked.
16 */
17 checkedIcon?: React.ReactNode;
18 /**
19 * Override or extend the styles applied to the component.
20 */
21 classes?: Partial<SwitchClasses>;
22 /**
23 * The color of the component.
24 * It supports both default and custom theme colors, which can be added as shown in the
25 * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
26 * @default 'primary'
27 */
28 color?: OverridableStringUnion<
29 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'default',
30 SwitchPropsColorOverrides
31 >;
32 /**
33 * If `true`, the component is disabled.
34 */
35 disabled?: boolean;
36 /**
37 * The icon to display when the component is unchecked.
38 */
39 icon?: React.ReactNode;
40 /**
41 * The size of the component.
42 * `small` is equivalent to the dense switch styling.
43 * @default 'medium'
44 */
45 size?: OverridableStringUnion<'small' | 'medium', SwitchPropsSizeOverrides>;
46 /**
47 * The system prop that allows defining system overrides as well as additional CSS styles.
48 */
49 sx?: SxProps<Theme>;
50 /**
51 * The value of the component. The DOM API casts this to a string.
52 * The browser uses "on" as the default value.
53 */
54 value?: unknown;
55}
56
57/**
58 *
59 * Demos:
60 *
61 * - [Switch](https://mui.com/material-ui/react-switch/)
62 * - [Transfer List](https://mui.com/material-ui/react-transfer-list/)
63 *
64 * API:
65 *
66 * - [Switch API](https://mui.com/material-ui/api/switch/)
67 * - inherits [IconButton API](https://mui.com/material-ui/api/icon-button/)
68 */
69export default function Switch(props: SwitchProps): React.JSX.Element;