react-native-paper
Version:
Material design for React Native
48 lines • 1.34 kB
TypeScript
import * as React from 'react';
import { StyleProp, Switch as NativeSwitch, ViewStyle } from 'react-native';
import type { ThemeProp } from '../../types';
export type Props = React.ComponentPropsWithRef<typeof NativeSwitch> & {
/**
* Disable toggling the switch.
*/
disabled?: boolean;
/**
* Value of the switch, true means 'on', false means 'off'.
*/
value?: boolean;
/**
* Custom color for switch.
*/
color?: string;
/**
* Callback called with the new value when it changes.
*/
onValueChange?: Function;
style?: StyleProp<ViewStyle>;
/**
* @optional
*/
theme?: ThemeProp;
};
/**
* Switch is a visual toggle between two mutually exclusive states — on and off.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { Switch } from 'react-native-paper';
*
* const MyComponent = () => {
* const [isSwitchOn, setIsSwitchOn] = React.useState(false);
*
* const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn);
*
* return <Switch value={isSwitchOn} onValueChange={onToggleSwitch} />;
* };
*
* export default MyComponent;
* ```
*/
declare const Switch: ({ value, disabled, onValueChange, color, theme: themeOverrides, ...rest }: Props) => React.JSX.Element;
export default Switch;
//# sourceMappingURL=Switch.d.ts.map