UNPKG

1.35 kBTypeScriptView Raw
1import * as React from 'react';
2import { StyleProp, Switch as NativeSwitch, ViewStyle } from 'react-native';
3import type { ThemeProp } from '../../types';
4export declare type Props = React.ComponentPropsWithRef<typeof NativeSwitch> & {
5 /**
6 * Disable toggling the switch.
7 */
8 disabled?: boolean;
9 /**
10 * Value of the switch, true means 'on', false means 'off'.
11 */
12 value?: boolean;
13 /**
14 * Custom color for switch.
15 */
16 color?: string;
17 /**
18 * Callback called with the new value when it changes.
19 */
20 onValueChange?: Function;
21 style?: StyleProp<ViewStyle>;
22 /**
23 * @optional
24 */
25 theme?: ThemeProp;
26};
27/**
28 * Switch is a visual toggle between two mutually exclusive states — on and off.
29 *
30 * ## Usage
31 * ```js
32 * import * as React from 'react';
33 * import { Switch } from 'react-native-paper';
34 *
35 * const MyComponent = () => {
36 * const [isSwitchOn, setIsSwitchOn] = React.useState(false);
37 *
38 * const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn);
39 *
40 * return <Switch value={isSwitchOn} onValueChange={onToggleSwitch} />;
41 * };
42 *
43 * export default MyComponent;
44 * ```
45 */
46declare const Switch: ({ value, disabled, onValueChange, color, theme: themeOverrides, ...rest }: Props) => React.JSX.Element;
47export default Switch;
48//# sourceMappingURL=Switch.d.ts.map
\No newline at end of file