I'm using react-native-paper
, I would like to make a button with bigger dimensions than normal, as seen in the gif.
I've tried using both height
and padding
, but both don't work properly.
What you see in the gif is the example with padding.
only way to click is in the center, in other places the event does not happen.
Can you give me a hand?
<Button
mode="contained"
labelStyle={{ color: Colors.white }}
style={{ padding: 30 }}
onPress={() => console.log('Pressed')}>
Start
</Button>
I'm using react-native-paper
, I would like to make a button with bigger dimensions than normal, as seen in the gif.
I've tried using both height
and padding
, but both don't work properly.
What you see in the gif is the example with padding.
only way to click is in the center, in other places the event does not happen.
Can you give me a hand?
<Button
mode="contained"
labelStyle={{ color: Colors.white }}
style={{ padding: 30 }}
onPress={() => console.log('Pressed')}>
Start
</Button>
Share
asked Dec 1, 2020 at 21:03
PaulPaul
4,48615 gold badges67 silver badges153 bronze badges
1
- Have you found a solution for the above? – ale917k Commented Oct 26, 2021 at 16:29
2 Answers
Reset to default 8YOU CAN USE
contentStyle
EXAMPLE
<Button
onPress={() => {}}
style={styles.pleteFormButton}
styleText={styles.pleteFormButtonText}
contentStyle={{ // <--- HERE-----
paddingVertical: 10,
}}
preset="outlined"
/>
react-native-papper
has these three props to pass styles
contentStyle Type: StyleProp Style of button's inner content. Use this prop to apply custom height and width and to set the icon on the right with flexDirection: 'row-reverse'.
style Type: StyleProp
labelStyle Type: StyleProp Style for the button text.
View documentation react native paper
you can create a touchablehighlight view around the button and call the same onPress function. something like this:
<TouchableHighlight onPress={() => console.log('Pressed')}>
<View
style={{
height: 70,
width: 110,
borderRadius: 5,
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center',
}}>
<Button
mode="contained"
labelStyle={{ color: 'blue' }}
onPress={() => console.log('Pressed')}>
Start
</Button>
</View>
</TouchableHighlight>