1import { Button } from 'react-native-elements';
2import Icon from 'react-native-vector-icons/FontAwesome';
3
4<View style={styles.buttonContainer}>
5<Button title='update state' onPress={do something}/>
6</View>
7
8or
9
10<Button
11 title="Solid Button"
12/>
13
14<Button
15 title="Outline button"
16 type="outline"
17/>
18
19<Button
20 title="Clear button"
21 type="clear"
22/>
23
24<Button
25 icon={
26 <Icon
27 name="arrow-right"
28 size={15}
29 color="white"
30 />
31 }
32 title="Button with icon component"
33/>
34
35<Button
36 icon={{
37 name: "arrow-right",
38 size: 15,
39 color: "white"
40 }}
41 title="Button with icon object"
42/>
43
44<Button
45 icon={
46 <Icon
47 name="arrow-right"
48 size={15}
49 color="white"
50 />
51 }
52 iconRight
53 title="Button with right icon"
54/>
55
56<Button
57 title="Loading button"
58 loading
59/>
60
61Source:
62https://reactnativeelements.com/docs/button/
1var tapSpeed = React.createClass({
2 render: function() {
3 return (
4 <View style={styles.container}>
5 <Text style={styles.welcome}>
6 Tap me as fast as you can!
7 </Text>
8 <View style={styles.button}>
9 !
10 </View>
11 </View>
12 );
13 }
14});
15
16var styles = StyleSheet.create({
17 container: {
18 flex: 1,
19 justifyContent: 'center',
20 alignItems: 'center',
21 backgroundColor: '#FFCCCC'
22 },
23 welcome: {
24 fontSize: 20,
25 textAlign: 'center',
26 margin: 10
27 },
28 button: {
29 textAlign: 'center',
30 color: '#ffffff',
31 marginBottom: 7,
32 border: 1px solid blue,
33 borderRadius: 2px
34 }
35});
1import { Button } from 'react-native-elements';
2import Icon from 'react-native-vector-icons/FontAwesome';
3
4<Button
5 title="Solid Button"
6/>
7
8<Button
9 title="Outline button"
10 type="outline"
11/>
12
13<Button
14 title="Clear button"
15 type="clear"
16/>
17
18<Button
19 icon={
20 <Icon
21 name="arrow-right"
22 size={15}
23 color="white"
24 />
25 }
26 title="Button with icon component"
27/>
28
29<Button
30 icon={{
31 name: "arrow-right",
32 size: 15,
33 color: "white"
34 }}
35 title="Button with icon object"
36/>
37
38<Button
39 icon={
40 <Icon
41 name="arrow-right"
42 size={15}
43 color="white"
44 />
45 }
46 iconRight
47 title="Button with right icon"
48/>
49
50<Button
51 title="Loading button"
52 loading
53/>
54
1<Button
2title="click me"
3onPress={() => console.log("you clicked a button")}
4/>
5// <Button /> does not accept a style other then color but thats that.
6// if you want a custom button you need to use <Pressable /> or any thing else-
7//- the thing you want to press just need to have onPress on it.
8
9<Text onPress={() => console.log("you pressed a text")}>click me</Text>
10
11
12<Text onPress={() => function()}>click me</Text>
13//function is your own function.
14
15//if you want the thing you press on to chance so the user can see that they puched it.
16//you can use the Touchable component.
17//here we are using the TouchableOpactity where the opacity change when it is pressed.
18<TouchableOpacity onPress={() => console.log("you pressed a touchableOpacty component")}>
19<Text>click me</Text>
20</TouchableOpacity>
21//the best option might be <TouchableOpacity></TouchableOpacity> to make your own button
22
23<Pressable onPress={() => console.log("you pressed me")}><Text>click me</Text></Pressable>
24//as you can see you can use a lot of thing as a button but if you usethese
25//you can style them as you want.
26//rember you need to import Touchable and Pressable before you can use em.
27
28