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 modal

Import

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

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.
isGlassbooleanfalseApply glassmorphism to the ModalContent panel.
glassTint'default' | 'light' | 'dark'Theme-derivedTint for the content panel's glass effect.
glassIntensitynumber70Intensity (0-100) for the content panel's glass effect.

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.