Skip to main content

Modal

Modal renders content above the enclosing view. It includes a configurable backdrop and can be dismissed by pressing outside the modal content.

Import

import { Modal } from '@ui-kitten/components';

Basic Usage

import React, { useState } from 'react';
import { StyleSheet } from 'react-native';
import { Layout, Modal, Card, Text, Button } from '@ui-kitten/components';

const ModalExample = () => {
const [visible, setVisible] = useState(false);

return (
<Layout style={{ flex: 1, padding: 16 }}>
<Button onPress={() => setVisible(true)}>Show Modal</Button>

<Modal
visible={visible}
onBackdropPress={() => setVisible(false)}
backdropStyle={styles.backdrop}
>
<Card disabled>
<Text>This is a modal dialog.</Text>
<Button onPress={() => setVisible(false)}>Dismiss</Button>
</Card>
</Modal>
</Layout>
);
};

const styles = StyleSheet.create({
backdrop: {
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
});

Props

PropertyTypeDefaultDescription
visiblebooleanfalseWhether the modal is visible.
onBackdropPress() => voidundefinedCalled when the backdrop is pressed.
backdropStyleViewStyleundefinedStyle applied to the backdrop.
childrenReactNode-Content rendered inside the modal.

Storybook

Live examples coming soon via Storybook.