Modal
Modal, a React Native component for iOS, Android and web: A centered dialog with scrolling content and a footer.
Usage
import { useState } from 'react';
import { Button } from './components/ui/button';
import { Modal } from './components/ui/modal';
import { Stack } from './components/ui/stack';
import { Text } from './components/ui/text';
export default function Example() {
const [open, setOpen] = useState(false);
return (
<>
<Button variant="outline" onPress={() => setOpen(true)}>Delete account</Button>
<Modal
open={open}
onOpenChange={setOpen}
title="Delete your account?"
description="This removes your orders and addresses."
footer={
<Stack direction="horizontal" gap={2} justify="flex-end">
<Button variant="ghost" onPress={() => setOpen(false)}>Keep it</Button>
<Button variant="danger" onPress={() => setOpen(false)}>Delete</Button>
</Stack>
}
>
<Text>Escape, the backdrop and the close button all dismiss this dialog.</Text>
</Modal>
</>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | ||
defaultOpen | boolean | false | |
onOpenChange | (open: boolean) => void | ||
title | string | ||
description | string | ||
children | ReactNode | ||
footer | ReactNode | Action buttons. | |
dismissible | boolean | true | When false, backdrop, back button and Escape do not close it, and no close button is shown. Require a choice in the footer. |
closeLabel | string | 'Close' | |
style | StyleProp<ViewStyle> | ||
testID | string | ||
native | boolean | Renders the system alert when `@leoanimesh/ferrule-native` is available. Only with `nativeActions`, because a system alert cannot hold React children; without them the Ferrule modal is used. | |
nativeActions | { label: string; role?: 'cancel' | 'destructive'; onPress?: () => void }[] | ||
label | string | ||
color | string | ||
onPress | () => void |