I might be missing something small here but I can't seem to get my <Modal>
ponent to center in my React Native app. Here is the code for the modal:
...
<Portal>
<Modal
visible={modalVisible}
onDismiss={hideModal}
contentContainerStyle={{
backgroundColor:'white',
padding:20,
width:'90%'
}}
>
<ScrollView>
<Text>A long chunk of text</Text>
<Button
onPress={hideModal}
color='#5F9DA5'
mode='contained'
dark={true}
>
Cool!
</Button>
</ScrollView>
</Modal>
</Portal>
...
I tried doing this as well:
<Modal
visible={modalVisible}
onDismiss={hideModal}
contentContainerStyle={{
backgroundColor:'white',
padding:20,
width:'90%',
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}}
>
Unsure what I'm missing here.
I might be missing something small here but I can't seem to get my <Modal>
ponent to center in my React Native app. Here is the code for the modal:
...
<Portal>
<Modal
visible={modalVisible}
onDismiss={hideModal}
contentContainerStyle={{
backgroundColor:'white',
padding:20,
width:'90%'
}}
>
<ScrollView>
<Text>A long chunk of text</Text>
<Button
onPress={hideModal}
color='#5F9DA5'
mode='contained'
dark={true}
>
Cool!
</Button>
</ScrollView>
</Modal>
</Portal>
...
I tried doing this as well:
<Modal
visible={modalVisible}
onDismiss={hideModal}
contentContainerStyle={{
backgroundColor:'white',
padding:20,
width:'90%',
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}}
>
Unsure what I'm missing here.
Share Improve this question asked Mar 23, 2022 at 19:37 patataskrpatataskr 3531 gold badge6 silver badges17 bronze badges1 Answer
Reset to default 7Try adding alignSelf:"center" to contentContainerStyle