Skip to main content

Modal

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

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>

Animation​

Open (scale)
<Modal isVisible={isVisible} onClose={() => setIsVisible(false)} animation="scale">
{/* ... */}
</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.
animation'fade' | 'slide' | 'scale''fade'How the content enters/exits. scale fades + scales the content; slide uses React Native's native slide.
contentAlign'center' | 'bottom' | 'left' | 'right''center'Where the content sits within the backdrop.
bgTVajraColors'surface'Background color token.
roundedTRoundedToken'r-4'Uniform corner radius; ignored if roundedT/roundedL/roundedR is set.
roundedTTRoundedTokenTop-corners-only radius, useful for bottom-anchored content.
roundedLTRoundedTokenLeft-corners-only radius, useful for right-anchored content.
roundedRTRoundedTokenRight-corners-only radius, useful for left-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`.