Modal

Modals are versatile dialogs that can display critical information, require user interaction, or show supplementary content without navigating away from the current screen.

Installation

$ cbui-cli install @crossbuildui/modal

Import

MyComponent.tsx
1import { 2 Modal, 3 ModalContent, 4 ModalHeader, 5 ModalBody, 6 ModalFooter 7} from '@/crossbuildui/modal'; 8import { Button } from '@/crossbuildui/button'; 9import { Text, View } from 'react-native'; 10import React, { useState } from 'react';

Modal Component

Props Overview

Modal Props

PROPTYPEDEFAULTDESCRIPTION
childrenReactNode-Content, usually ModalContent.
sizeModalSize'md'Modal width/height. See types for options.
radiusModalRadius'lg'Border radius of ModalContent.
shadowModalShadow'lg'Shadow of ModalContent.
backdrop'transparent' | 'opaque' | 'blur''opaque'Backdrop type.
scrollBehavior'inside' | 'outside''outside'Scroll behavior for overflow content.
placementModalPlacement'auto'Modal position on screen.
isOpenboolean-Controlled open state.
defaultOpenbooleanfalseInitial open state (uncontrolled).
isDismissablebooleantrueIf modal can be closed by backdrop click or escape/back.
hideCloseButtonbooleanfalseHide default close button in header.
closeButtonReactNode-Custom close button element.
animationPropsobject-Props for Animated.View (reanimated).
onOpenChange(isOpen: boolean) => void-Callback for open state changes.
onClose() => void-Callback when modal closes.
styleStyleProp<ViewStyle>-Style for ModalContent wrapper.
backdropStyleStyleProp<ViewStyle>-Style for the backdrop view.

ModalContent Props

PROPTYPEDESCRIPTION
childrenReactNodeContent of the modal dialog.
styleStyleProp<ViewStyle>Custom styles for the content container.

ModalHeader Props

PROPTYPEDESCRIPTION
childrenReactNodeContent of the header, e.g., title text.
styleStyleProp<ViewStyle>Custom styles for the header container.

ModalBody Props

PROPTYPEDESCRIPTION
childrenReactNodeMain content of the modal.
styleStyleProp<ViewStyle>Custom styles for the body container.

ModalFooter Props

PROPTYPEDESCRIPTION
childrenReactNodeContent for the footer, e.g., action buttons.
styleStyleProp<ViewStyle>Custom styles for the footer container.