Skip to main content

Modal

Overlay & Menus

Modal

Low-level modal primitive leveraging Portal, Backdrop, and focus trapping.

Usage

Build custom overlays or reuse as foundation for Dialog/Sheet experiences.

Highlights

  • Animated entry/exit hooks
  • Scroll locking and escape handling

When to use it

  • You need a bespoke overlay not covered by Dialog.
  • Compose multi-step flows on top of the modal base.

Examples

Default

Preview (Web)
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { Button } from 'react-native-molecules/components/Button';
import { Modal } from 'react-native-molecules/components/Modal';
import { Portal } from 'react-native-molecules/components/Portal';
import { Text } from 'react-native-molecules/components/Text';

const styles = StyleSheet.create({
  container: {
      width: 320,
      padding: 24,
      borderRadius: 24,
      backgroundColor: '#fff',
      alignItems: 'center',
      gap: 12,
  },
});

export default function Example() {
  const [open, setOpen] = useState(false);

  return (
      <>
          <Button onPress={() => setOpen(true)}>Show Modal</Button>
          <Portal>
              <Modal isOpen={open} onClose={() => setOpen(false)}>
                  <View style={styles.container}>
                      <Text>Modal Content</Text>
                      <Button variant="text" onPress={() => setOpen(false)}>
                          Close
                      </Button>
                  </View>
              </Modal>
          </Portal>
      </>
  );
}
PropTypeDefaultDescription
childrenRequiredReactNode
styleStyleProp<ViewStyle>
testIDstring | undefined
dismissibleboolean | undefined
overlayAccessibilityLabelstring | undefined
elevationMD3Elevation | undefined
isOpenboolean | undefined
onClose(() => void) | undefined
contentContainerStyleStyleProp<ViewStyle>
size"md" | "lg" | undefined
backdropStyleStyleProp<ViewStyle>
containerStyleStyleProp<ViewStyle>
Defined in react-native-molecules/components/Modal