Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-modalize

jeremybarbet151.7kMIT2.1.1TypeScript support: included

A highly customizable modal/bottom sheet that loves scrolling content.

react-native, react, native, modal, bottom sheet, bottom, sheet, scrollView, flatList, sectionList, scroll, swipe, keyboard, snap, android, ios

readme

Modalize

npm version

A highly customizable modal/bottom sheet that loves scrolling content.

This component has been built with react-native-gesture-handler to address the common issue of scrolling, swiping and handling the keyboard behaviors, you can face with react-native's modal.

This component comes with a ScrollView, the default renderer, a FlatList or a SectionList. They are all three built-in and make your life easier, just pass your content and Modalize will handle the rest for you. You can also have the possibility to pass your own custom renderer.

Simple Fixed Snapping Absolute FlatList Open Apple Facebook Slack

Installation

yarn add react-native-modalize react-native-gesture-handler
<summary>iOS</summary>
npx pod-install ios
<summary>Android</summary>

React Native <= 0.59

Follow this guide to complete the Android installation.

React Native > 0.60

You don't need to follow the guide mentioned above because autolinking from React already did the steps.

Usage

Here is a quick example, using the default ScrollView renderer.

import React, { useRef } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { Modalize } from 'react-native-modalize';

export const App = () => {
  const modalizeRef = useRef<Modalize>(null);

  const onOpen = () => {
    modalizeRef.current?.open();
  };

  return (
    <>
      <TouchableOpacity onPress={onOpen}>
        <Text>Open the modal</Text>
      </TouchableOpacity>

      <Modalize ref={modalizeRef}>...your content</Modalize>
    </>
  );
};

Documentation

Please check out the full documentation available here to find all about the props, methods and examples of Modalize's usage.

changelog

Changelog

All notable changes to this project will be documented in this file.

[2.1.1] - 2022-08-10

👀 Bug Fixes

[2.1.0] - 2022-08-10

🎉 New features

📜 Documentation

[2.0.13] - 2021-12-24

👀 Bug Fixes

[2.0.12] - 2021-11-11

👀 Bug Fixes

[2.0.11] - 2021-11-07

👀 Bug Fixes

[2.0.10] - 2021-10-14

👀 Bug Fixes

[2.0.9] - 2021-10-14

🎉 New features

[2.0.8] - 2020-12-04

👀 Bug Fixes

  • Revert: Position on orientation change
  • Revert: If color scheme is "dark", setting modal backgroundColor to black

[2.0.7] - 2020-12-03

👀 Bug Fixes

  • Fix disableScrollIfPossible type (#283) (9b8563)
  • Add missing word at callbacks section (#272) (5880ef)
  • Added devices support for iPhone 12 devices (#294) (e80029)
  • Position on orientation change (#274) (f0d75a)

✨ Improvements

  • Allow custom renderer to receive function or react node (#291) (26a4c1)
  • If color scheme is "dark", setting modal backgroundColor to black (#278) (d5ccbb)

[2.0.6] - 2020-08-27

👀 Bug Fixes

  • Fix adjustToContentHeight on Android (#219) (bebd6e)

✨ Improvements

[2.0.5] - 2020-07-25

👀 Bug Fixes

✨ Improvements

[2.0.4] - 2020-05-20

👀 Bug Fixes

[2.0.3] - 2020-05-08

👀 Bug Fixes

[2.0.0] - 2020-05-05

Really happy to release this brand new major version for react-native-modalize.

I have been working on it for the last couple of weeks. Many thanks for the people who contributed, opened PR and found issues. High five to @xxsnakerxx for having contributing many times in the last few weeks!

  • I rewrote the package using function component, that makes the library lighter, faster and using the latest React practices.
  • I also rewrote and reorganize most of the documentation to be easier to read, with way more information about the props, methods, usages and more examples.
  • Finally, there was a lot of issues about Modalize not being able to be displayed on top of a bottom tab navigation (e.g. with react-navigation). I released a new package called react-native-portalize to be able to solve this issue. It works with Modalize but can also be useful in other context.

💣 Breaking change

  • The required ref to open or close Modalize is still the same ref={modalizeRef}, modalizeRef.current.open(). However, you won't be able to access scrollTo, scrollToIndex on the content renderer using this ref anymore. You will need to use the new ref contentRef that will give you access to the content methods. contentRef={contentRef}, contentRef.current.getScrollResponder().scrollTo(...). "content" stands for ScrollView, FlatList or SectionList depending the content renderer you are using.

🎉 New features

✨ Improvements

  • Allow alwaysOpen and ajustToContentHeight props to work at the same time #172 (c37ecd5)
  • Simplified and fixed adjustToContentHeight props by @xxsnakerxx (#166) (0c5d908)
  • Recalculate when toggle adjustToContentHeight prop (6fc762d)
  • Basic support for react-native-web (8d98896)
  • Enable horizontal scrolling for ScrollView by @xxsnakerxx (#121) (49ec5ae)
  • Allow alwaysOpen to open to default position (bed354e)
  • scrollTo methods updated for flatList and sectionList by @xxsnakerxx (#126) (038a5ab)

👀 Bug Fixes

  • Check heights of each Header/Footer/Floating components when used with ajustToContentHeight (#149) (7e219c)
  • Prevent overlay press closing alwaysOpen by @jordanl17 (f0eb9b)
  • Avoid onScrollBeginDrag overriding default behavior by @xxsnakerxx (#180) (14f20cb)
  • Make sure animate is enable when closing modalize (df49ca5) f1cd77a601897b1baadafa12a8fb2f55ccd891cf))
  • Translation check for panGesture value (a46fa43)
  • Cancel translation when ScrollView is not scrolled to the top (a965fbe)
  • Core uses nativeDriver, exposes props for panGestureAnimatedValue only (19bf709)
  • Flickering while scrolling/panning (fe267cd)
  • Pass onLayout if using adjustToContentHeight props (9b52c0e)
  • Rework initial open/close states (534dc69)
  • Take out modalPosition logic out of onPositionChange props check (a478ef1)
  • Hardware back button press handler by @xxsnakerxx (#148) (7e1cbf0)
  • Only trigger positive values (6e19ee8)
  • Remove back press listener on unmount by @Grohden (#137) (eafb8ee), closes #111
  • Enable scroll when keyboard is toggle (c7a7dbe)
  • Make sure we don't enable scroll by mistake (716f5ab)
  • Avoid events to be trigger twice (#130) (9413350)
  • Disable scroll when using adjustToContentHeight (5550f3f)
  • Disable scroll with alwaysOpen props on init (990cba7)
  • And many more...

[1.3.6] - 2019-12-28

Changed

  • Use timing function onAnimateClose

[1.3.5] - 2019-12-27

Changed

  • Revert bouncing translate

[1.3.4] - 2019-12-26

Changed

  • Better spring/timing props
  • Mask for empty space with bounce

[1.3.3] - 2019-12-20

Changed

  • Fix bouncing on opening animation
  • Clean examples from unused functions

[1.3.2] - 2019-12-20

Added

  • New argument to the close method to reset to initial position alwaysOpen modal (close('alwaysOpen'))

Changed

  • Fix glitchy issue onAnimateOpen cause by extrapolate: clamp and spring animation

[1.3.1] - 2019-12-19

Changed

  • Remove uppercase from options.ts file

[1.3.0] - 2019-12-19

Added

  • Dev tools (prettier, commitlint)

Changed

  • BREAKING Move to name import (before) import Modalize from 'react-native-modalize' -> (after) import { Modalize } from 'react-native-modalize'
  • Fix overlay press to dismiss by @Esirei
  • Fix initial state when using alwaysOpen by @benjaminreid
  • Change renovate to keep all changes in same PR
  • Update packages
  • Update examples
  • Rename source files

[1.2.2] - 2019-10-13

Changed

  • Fix flickering issue with adjustToContentHeight by @charpeni
  • Add renovate to keep packages up-to-date
  • Upgrade dependencies

[1.2.1] - 2019-08-02

Changed

  • Fix issue with hasAbsoluteStyle util
  • Fix flickering on swipe gesture
  • Update documentation
  • Add changelog file

[1.2.0] - 2019-07-31

Added

  • openAnimationConfig / closeAnimationConfig to control the animations by @WrathChaos.
  • modalHeight to set a specific height to the modal by @WrathChaos.

Changed

  • BREAKING style props renamed to modalStyle
  • BREAKING height props renamed to snapPoint
  • Create utils file to make internal source lighter

[1.1.1] - 2019-06-21

Added

  • More gif examples for all behaviors possible

Changed

  • Move hardwareBackPress to open and close animation functions

[1.1.0] - 2019-06-20

Added

  • Add alwaysOpen props, to keep the modal always open on the bottom of the screen
  • Bump js-yaml package because of security warning

[1.0.0] - 2019-06-06

Changed

  • Improve documentation
  • Refactor all examples, and make it easier to use them
  • Move examples from React.class to stateless function
  • Null check on component passed to Modalize
  • Bump packages from source code and examples