Reputation: 4434
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>
Upvotes: 3
Views: 4373
Reputation: 791
YOU CAN USE
contentStyle
EXAMPLE
<Button
onPress={() => {}}
style={styles.completeFormButton}
styleText={styles.completeFormButtonText}
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
Upvotes: 8
Reputation: 2647
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>
Upvotes: 0