UNPKG

3.6 kBTypeScriptView Raw
1import * as React from 'react';
2import { GestureResponderEvent, StyleProp, TextStyle, ViewStyle } from 'react-native';
3import type { ThemeProp } from 'src/types';
4import type { IconSource } from '../Icon';
5declare type ConditionalValue = {
6 /**
7 * Array of the currently selected segmented button values.
8 */
9 value: string[];
10 /**
11 * Support multiple selected options.
12 */
13 multiSelect: true;
14 /**
15 * Function to execute on selection change
16 */
17 onValueChange: (value: string[]) => void;
18} | {
19 /**
20 * Value of the currently selected segmented button.
21 */
22 value: string;
23 /**
24 * Support multiple selected options.
25 */
26 multiSelect?: false;
27 /**
28 * Function to execute on selection change
29 */
30 onValueChange: (value: string) => void;
31};
32export declare type Props = {
33 /**
34 * Buttons to display as options in toggle button.
35 * Button should contain the following properties:
36 * - `value`: value of button (required)
37 * - `icon`: icon to display for the item
38 * - `disabled`: whether the button is disabled
39 * - `accessibilityLabel`: acccessibility label for the button. This is read by the screen reader when the user taps the button.
40 * - `checkedColor`: custom color for checked Text and Icon
41 * - `uncheckedColor`: custom color for unchecked Text and Icon
42 * - `onPress`: callback that is called when button is pressed
43 * - `label`: label text of the button
44 * - `showSelectedCheck`: show optional check icon to indicate selected state
45 * - `style`: pass additional styles for the button
46 * - `testID`: testID to be used on tests
47 */
48 buttons: {
49 value: string;
50 icon?: IconSource;
51 disabled?: boolean;
52 accessibilityLabel?: string;
53 checkedColor?: string;
54 uncheckedColor?: string;
55 onPress?: (event: GestureResponderEvent) => void;
56 label?: string;
57 showSelectedCheck?: boolean;
58 style?: StyleProp<ViewStyle>;
59 labelStyle?: StyleProp<TextStyle>;
60 testID?: string;
61 }[];
62 /**
63 * Density is applied to the height, to allow usage in denser UIs
64 */
65 density?: 'regular' | 'small' | 'medium' | 'high';
66 style?: StyleProp<ViewStyle>;
67 theme?: ThemeProp;
68} & ConditionalValue;
69/**
70 * Segmented buttons can be used to select options, switch views or sort elements.</br>
71 *
72 * ## Usage
73 * ```js
74 * import * as React from 'react';
75 * import { SafeAreaView, StyleSheet } from 'react-native';
76 * import { SegmentedButtons } from 'react-native-paper';
77 *
78 * const MyComponent = () => {
79 * const [value, setValue] = React.useState('');
80 *
81 * return (
82 * <SafeAreaView style={styles.container}>
83 * <SegmentedButtons
84 * value={value}
85 * onValueChange={setValue}
86 * buttons={[
87 * {
88 * value: 'walk',
89 * label: 'Walking',
90 * },
91 * {
92 * value: 'train',
93 * label: 'Transit',
94 * },
95 * { value: 'drive', label: 'Driving' },
96 * ]}
97 * />
98 * </SafeAreaView>
99 * );
100 * };
101 *
102 * const styles = StyleSheet.create({
103 * container: {
104 * flex: 1,
105 * alignItems: 'center',
106 * },
107 * });
108 *
109 * export default MyComponent;
110 *```
111 */
112declare const SegmentedButtons: ({ value, onValueChange, buttons, multiSelect, density, style, theme: themeOverrides, }: Props) => React.JSX.Element;
113export default SegmentedButtons;
114export { SegmentedButtons as SegmentedButtons };
115//# sourceMappingURL=SegmentedButtons.d.ts.map
\No newline at end of file