Skip to main content

Modal

A centered (or bottom-anchored) dialog rendered in a React Native Modal, with a fading backdrop. Sheet is built on top of this component using contentAlign="bottom".

Open modal
function ConfirmModal() {
const [isVisible, setIsVisible] = useState(false);

return (
<>
<Button label="Open modal" onPress={() => setIsVisible(true)} />
<Modal isVisible={isVisible} onClose={() => setIsVisible(false)}>
<Text variant="subheading" mb="s-2">
Delete item?
</Text>
<Text color="textMuted" mb="s-4">
This action cannot be undone.
</Text>
<Row gap="s-2" justify="flex-end">
<Button variant="ghost" label="Cancel" onPress={() => setIsVisible(false)} />
<Button variant="solid" label="Delete" onPress={() => setIsVisible(false)} />
</Row>
</Modal>
</>
);
}

Bottom-anchored

Open bottom modal
<Modal isVisible={isVisible} onClose={() => setIsVisible(false)} contentAlign="bottom" roundedT="r-4">
<Text variant="subheading" mb="s-2">
Bottom-anchored content
</Text>
<Button label="Close" onPress={() => setIsVisible(false)} />
</Modal>

Props

PropTypeDefaultDescription
isVisiblebooleanRequired. Controls whether the modal is shown.
onClose() => voidRequired. Called on backdrop press and Android hardware back.
childrenReactNodeRequired. Modal content.
closeOnBackdropPressbooleantrueWhether tapping the backdrop calls onClose.
contentAlign'center' | 'bottom''center'Where the content sits within the backdrop.
bgTVajraColors'surface'Background color token.
roundedTRoundedToken'r-4'Uniform corner radius; ignored if roundedT is set.
roundedTTRoundedTokenTop-corners-only radius, useful for bottom-anchored content.
pTSpacingToken's-4'Padding token applied to the content container.
backdropColorTVajraColors'overlay'Backdrop color token.
testIDstringBase test ID; also applied to the backdrop and content as `${testID}-backdrop` / `${testID}-content`.