Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set borderRadius on a react-native modal?

I have a react-native Modal, I would like to render it with rounded corners like this: Modal example

but if I define it like this:

 <Modal
       style={{
                borderTopLeftRadius: 10,
                borderTopRightRadius: 10,
                overflow: 'hidden',
            }}

nothing happens (at least on Android). I also tried to wrap the Modal with a View with the same style but with no more success.

What am I doing wrong?

like image 574
Simon Avatar asked Dec 10 '19 16:12

Simon


People also ask

How do you give a border radius to a modal?

You can just use rounded-0 bootstrap class. Show activity on this post. Show activity on this post. border-radius removes the rounded corners while border removes all borders (left, right, top, bottom) around the modal.

How do I customize modal in react native?

In your components folder, create a file called Modal. tsx and add the following code: import React from "react"; import { StyleSheet, View, Text, Button } from "react-native"; import RNModal from "react-native-modal"; type ModalProps = { isVisible: boolean; children: React.

How do I dim the background in react native modal?

You must add statusBarTranslucent props to Modal component and set it to true. Then you will get your desired output. No need to set transparent props to true or any other tedious styles.


1 Answers

The solution is to put a View inside the Modal (right after its decalration) with this style:

      <Modal>
          <View
            style={{
              borderTopLeftRadius: 10,
              borderTopRightRadius: 10,
              overflow: 'hidden',
            }}
          >
      </Modal>
like image 121
Simon Avatar answered Nov 05 '22 02:11

Simon