Socket
Book a DemoInstallSign in
Socket

react-native-awesome-modal

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-awesome-modal

A flexible and reusable modal.

0.2.0
latest
Source
npmnpm
Version published
Weekly downloads
11
Maintainers
2
Weekly downloads
 
Created
Source

react-native-awesome-modal

A flexible and reusable modal.

Install

 npm install react-native-awesome-modal --save

or

 yarn add react-native-awesome-modal

Usage

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>
  )
};
.....

Props

The props below are used to configure and style the modal.

PropTypeOptionalDefaultDescription
enableScrollbooleanYesfalseContainer of the modal's content will be a ScrollView instead of a View if set to true.
hasTabBarbooleanYesfalseWhether the app has a tab bar (i.e. requires bottom padding for the modal)
overflowShowbooleanYesfalseWhether to show overflown elements.
closeOnPressOutsidebooleanYestrueWhether to close the modal on press outside of it
modalBottomMarginnumberYes45The bottom margin of modal.
isCenteredbooleanYesfalseWhether the modal is centered on the screen. The value supplied to modalBottomMargin will be ignored if isCentered is set to True.
onClose() => voidYesFunction to call when the modal closes.
onPressOutside() => voidYesFunction to call when the user presses outside of the modal.
modalContainerStyleStylePropYesSee awesome-modal.tsxThe modal's container style.
modalInnerContainerStyleStylePropYesSee awesome-modal.tsxThe modal's content container style.
modalOverlayStyleStylePropYesSee awesome-modal.tsxThe modal's overlay style (i.e the translucent overlay behind the modal).
modalRef(ref: AwesomeModalundefined) => voidYes

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Denise-Ng

💻 📖 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

react

FAQs

Package last updated on 18 Aug 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.