UNPKG

1.77 kBTypeScriptView Raw
1import * as React from 'react';
2declare type Props = {
3 /**
4 * Function to execute on selection change.
5 */
6 onValueChange: (value: string) => void;
7 /**
8 * Value of the currently selected radio button.
9 */
10 value: string;
11 /**
12 * React elements containing radio buttons.
13 */
14 children: React.ReactNode;
15};
16export declare type RadioButtonContextType = {
17 value: string;
18 onValueChange: (item: string) => void;
19};
20export declare const RadioButtonContext: React.Context<RadioButtonContextType>;
21/**
22 * Radio button group allows to control a group of radio buttons.
23 *
24 * <div class="screenshots">
25 * <figure>
26 * <img class="medium" src="screenshots/radio-button-group-android.gif" />
27 * <figcaption>Android</figcaption>
28 * </figure>
29 * <figure>
30 * <img class="medium" src="screenshots/radio-button-group-ios.gif" />
31 * <figcaption>iOS</figcaption>
32 * </figure>
33 * </div>
34 *
35 * ## Usage
36 * ```js
37 * import * as React from 'react';
38 * import { View } from 'react-native';
39 * import { RadioButton, Text } from 'react-native-paper';
40 *
41 * const MyComponent = () => {
42 * const [value, setValue] = React.useState('first');
43 *
44 * return (
45 * <RadioButton.Group onValueChange={newValue => setValue(newValue)} value={value}>
46 * <View>
47 * <Text>First</Text>
48 * <RadioButton value="first" />
49 * </View>
50 * <View>
51 * <Text>Second</Text>
52 * <RadioButton value="second" />
53 * </View>
54 * </RadioButton.Group>
55 * );
56 * };
57 *
58 * export default MyComponent;
59 *```
60 */
61declare const RadioButtonGroup: {
62 ({ value, onValueChange, children }: Props): JSX.Element;
63 displayName: string;
64};
65export default RadioButtonGroup;
66export { RadioButtonGroup };