UNPKG

2.19 kBTypeScriptView Raw
1import * as React from 'react';
2import { GestureResponderEvent, StyleProp, ViewStyle, View, Animated, ColorValue } from 'react-native';
3import type { ThemeProp } from '../../types';
4import type { IconSource } from '../Icon';
5export declare type Props = {
6 /**
7 * Icon to display for the `ToggleButton`.
8 */
9 icon: IconSource;
10 /**
11 * Size of the icon.
12 */
13 size?: number;
14 /**
15 * Custom text color for button.
16 */
17 iconColor?: string;
18 /**
19 * Color of the ripple effect.
20 */
21 rippleColor?: ColorValue;
22 /**
23 * Whether the button is disabled.
24 */
25 disabled?: boolean;
26 /**
27 * Accessibility label for the `ToggleButton`. This is read by the screen reader when the user taps the button.
28 */
29 accessibilityLabel?: string;
30 /**
31 * Function to execute on press.
32 */
33 onPress?: (value?: GestureResponderEvent | string) => void;
34 /**
35 * Value of button.
36 */
37 value?: string;
38 /**
39 * Status of button.
40 */
41 status?: 'checked' | 'unchecked';
42 style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
43 /**
44 * @optional
45 */
46 theme?: ThemeProp;
47 ref?: React.RefObject<View>;
48 /**
49 * testID to be used on tests.
50 */
51 testID?: string;
52};
53/**
54 * Toggle buttons can be used to group related options. To emphasize groups of related toggle buttons,
55 * a group should share a common container.
56 *
57 * ## Usage
58 * ```js
59 * import * as React from 'react';
60 * import { ToggleButton } from 'react-native-paper';
61 *
62 * const ToggleButtonExample = () => {
63 * const [status, setStatus] = React.useState('checked');
64 *
65 * const onButtonToggle = value => {
66 * setStatus(status === 'checked' ? 'unchecked' : 'checked');
67 * };
68 *
69 * return (
70 * <ToggleButton
71 * icon="bluetooth"
72 * value="bluetooth"
73 * status={status}
74 * onPress={onButtonToggle}
75 * />
76 * );
77 * };
78 *
79 * export default ToggleButtonExample;
80 *
81 * ```
82 */
83declare const ToggleButton: import("../../utils/forwardRef").ForwardRefComponent<View, Props>;
84export default ToggleButton;
85export { ToggleButton };
86//# sourceMappingURL=ToggleButton.d.ts.map
\No newline at end of file