Skip to main content
Version: 1.x

Modal

The Modal component is a basic way to present content above an enclosing view.

Import

import { Modal } from '@tra-tech/react-native-kitra';

Usage

import { Modal } from '@tra-tech/react-native-kitra';
import { useState } from 'react';
import { Text, TouchableOpacity, View } from 'react-native';

const App = () => {

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

return (
<>
<View style={{ alignItems: 'center' }}>
<TouchableOpacity onPress={() => setVisible(true)}>
<Text>Show Modal</Text>
</TouchableOpacity>
</View>
<Modal visible={visible} modalStyle={{ width: '100%', height: '100%', backgroundColor: '#D7D1E9', alignItems: 'center', justifyContent: 'center' }}>
<TouchableOpacity onPress={() => setVisible(false)}>
<Text>Hide Modal</Text>
</TouchableOpacity>
</Modal>
</>
);
};

export default App;

Props

Prop nameTypeRequiredDescription
containerStyleStyleProp<ViewStyle>NoAdditional styles to apply to the modal container.
modalStyleStyleProp<ViewStyle>NoAdditional styles to apply to the modal component.
visiblebooleanNoVisibility status. Default value: false
childrenReact.ReactNodeNoContent of the modal.
...ModalPropsModalPropsNoReact native modal props.
themeUITheme NoThe theme to use for the component.
typographyUITypographyNoThe typography to use for the component.