docs/public/3.0/dialog.html
Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks. To render the Dialog above other components, you'll need to wrap it with the Portal component.
import * as React from 'react';
import { View } from 'react-native';
import { Button, Paragraph, Dialog, Portal } from 'react-native-paper';
const MyComponent = () => {
const [visible, setVisible] = React.useState(false);
const showDialog = () => setVisible(true);
const hideDialog = () => setVisible(false);
return (
<View>
<Button onPress={showDialog}>Show Dialog</Button>
<Portal>
<Dialog visible={visible} onDismiss={hideDialog}>
<Dialog.Title>Alert</Dialog.Title>
<Dialog.Content>
<Paragraph>This is simple dialog</Paragraph>
</Dialog.Content>
<Dialog.Actions>
<Button onPress={hideDialog}>Done</Button>
</Dialog.Actions>
</Dialog>
</Portal>
</View>
);
};
export default MyComponent;
dismissable
Type: boolean
Default value: true
Determines whether clicking outside the dialog dismiss it.
onDismiss
Type: () => void
Callback that is called when the user dismisses the dialog.
visible
Type: boolean
Default value: false
Determines Whether the dialog is visible.
children (required)
Type: React.ReactNode
Content of the Dialog.
style
Type: StyleProp<ViewStyle>
theme
Type: Theme
These properties can be accessed on Dialog by using the dot notation, e.g. Dialog.Content.
Content
Type: static
Actions
Type: static
Title
Type: static
ScrollArea
Type: static