I’m trying to add an Icon
and some text in a Button
(also tried Chip
and Badge
from react-native-paper
). For some reason the Icon
is always a little above the text.
With View
it works perfectly, but once I introduce Button
, Chip
or Badge
, the items missalign.
// Working with View
<View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
<MaterialIcon name='access-time' size={iconSize2} color={themeColors[2]} />
<Text variant="titleLarge" style={{ color: themeColors[2], fontFamily: defaultFont }}> 12:00 - 21:30</Text>
</View>
// Missaligned with Button
<Button style={{ backgroundColor: themeColors[2], flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
<MaterialIcon name='access-time' size={iconSize2} color={'whitesmoke'} />
<Text variant="titleLarge" style={{ color: themeColors[2], fontFamily: defaultFont }}> 12:00 - 21:30</Text>
</Button>
Image for reference:
Can somebody tell me if I’m doing something incorrect?
Things tried:
- Add
paddingTop
toButton
- Add
marginTop
toIcon
- Change
height
ofButton
and/orIcon
2
Answers
In the documentation all the way at the bottom of the webpage there is a sample for
Icon
's withButton
's.Example that worked for me as well:
Try: