Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
react-native-awesome-modal
Advanced tools
A flexible and reusable modal.
npm install react-native-awesome-modal --save
or
yarn add react-native-awesome-modal
import {AwesomeModal} from 'react-native-awesome-modal'
const App: () => React$Node = () => {
// Have to use the useRef hook to control the modal
// from the parent component
const modalRef = useRef(null);
return (
<AwesomeModal
enableScroll
onClose={() => console.log('close')}
onPressOutside={() => console.log('outside')}
modalBottomMargin={0}
modalRef={(ref) => {modalRef.current = ref}}
modalContainerStyle={{
width: "99%",
maxHeight: 600,
borderTopRightRadius: 20,
borderTopLeftRadius: 20,
}}
modalOverlayStyle={{
backgroundColor: 'grey'
}}
>
// Place modal's content here as the component's child
<Text>HELLO!</Text>
<TouchableOpacity onPress={() => modalRef.current.scrollToTop()} style={styles.buttonStyle}>
<Text style={styles.buttonTextStyle}>Scroll to top</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => modalRef.current.close()} style={styles.buttonStyle}>
<Text style={styles.buttonTextStyle}>Close Modal</Text>
</TouchableOpacity>
</AwesomeModal>
)
};
.....
The props below are used to configure and style the modal.
Prop | Type | Optional | Default | Description |
---|---|---|---|---|
enableScroll | boolean | Yes | false | Container of the modal's content will be a ScrollView instead of a View if set to true. |
hasTabBar | boolean | Yes | false | Whether the app has a tab bar (i.e. requires bottom padding for the modal) |
overflowShow | boolean | Yes | false | Whether to show overflown elements. |
closeOnPressOutside | boolean | Yes | true | Whether to close the modal on press outside of it |
modalBottomMargin | number | Yes | 45 | The bottom margin of modal. |
isCentered | boolean | Yes | false | Whether the modal is centered on the screen. The value supplied to modalBottomMargin will be ignored if isCentered is set to True. |
onClose | () => void | Yes | Function to call when the modal closes. | |
onPressOutside | () => void | Yes | Function to call when the user presses outside of the modal. | |
modalContainerStyle | StyleProp | Yes | See awesome-modal.tsx | The modal's container style. |
modalInnerContainerStyle | StyleProp | Yes | See awesome-modal.tsx | The modal's content container style. |
modalOverlayStyle | StyleProp | Yes | See awesome-modal.tsx | The modal's overlay style (i.e the translucent overlay behind the modal). |
modalRef | (ref: AwesomeModal | undefined) => void | Yes |
Thanks goes to these wonderful people (emoji key):
Denise-Ng 💻 📖 💡 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
A flexible and reusable modal.
The npm package react-native-awesome-modal receives a total of 2 weekly downloads. As such, react-native-awesome-modal popularity was classified as not popular.
We found that react-native-awesome-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.