Import
Usage
Props
Controls modal visibility. Use state to toggle open/close.
Callback fired when modal should close (X button, overlay click if enabled).
Modal display mode:
default: Centered modal with max constraintsfull-screen: Bottom sheet on mobile, centered on desktopform: Two-column form layout with labels (requiresoptionsprop)web: Embeds external URL in iframe (requiresurlprop)lateral: Side panel from right edge
Modal header title text.
Optional subtitle below title.
Error message displayed at bottom in red background box.
Hides the X close button in top-right corner.
Hides the entire header section (title, subtitle, Header element).
Custom React element to render in header area below title/subtitle.
Custom React element to render in footer before the button.
Props for the action button in footer. If not provided, no footer is rendered.
Custom CSS properties for the modal container.
Custom CSS properties for the title section.
Custom CSS properties for the content area.
Custom CSS properties for the footer section.
Allow closing modal by clicking the dark overlay. Default:
false.Opacity of the dark overlay background (0-1). Default:
0.6.Content to display in the modal body.
Form Mode Props
Array of form field configurations for
type="form". Each item creates a labeled row or separator.id: Unique identifier (use"separator"for horizontal divider)title: Label text (left column, 112px width)Data: React element for input/content (right column)hidden: Conditionally hide this row
Web Mode Props
External URL to display in an iframe when
type="web". Modal height is set to 100% to accommodate iframe.Ref Methods
Programmatically close the modal. Access via ref.
Modal Sizes
Default Mode
- Width: 486px (max:
calc(100% - 96px)on desktop,calc(100% - 48px)on mobile) - Max height:
calc(100% - 96px)on desktop,calc(100% - 48px)on mobile - Border radius: 12px
- Position: Center of screen
Full-screen Mode
- Width: 100%
- Height: Slides from bottom
- Border radius:
12px 12px 0 0(top corners only) - Mobile-optimized: Bottom sheet style
Form Mode
- Width: 80% (max: 600px)
- Two-column layout: 112px labels, flexible content
Lateral Mode
- Width: 400px on desktop, 100% on mobile
- Height: 100%
- Slides from: Right edge
- Border radius: 0
Examples
Basic Modal
Form Modal
Web Modal (iframe)
Full-screen Modal
Lateral Panel
With Error Message
Using Ref
With Custom Header and Footer
Confirmation Dialog
Animations
Default Mode
- Open: Scales from 0.2 to 1, fades in, moves from 150% to 50% top
- Close: Reverses animation
- Duration: 0.3s ease-out
Full-screen Mode
- Open: Slides up from -100vh to 0px bottom
- Close: Slides down to -100vh
- Duration: 0.3s ease-out
Lateral Mode
- Open: Slides in from -100vw to 0 right
- Close: Slides out to -100vw
- Duration: 0.3s ease-out
Overlay
- Open: Fades to 0.6 opacity (or custom)
- Close: Fades to 0
- Duration: 0.3s ease-out
Styling Details
Header
- Position: Sticky (stays at top when scrolling)
- Padding: 10px 24px 16px (or 16px if no close button)
- Z-index: 100
Content
- Padding: 0 24px
- Overflow: Auto (scrollable)
Footer
- Position: Sticky (stays at bottom)
- Padding: 16px 24px (8px 16px on mobile)
- Background: White
- Alignment: Flex-end (right-aligned)
Close Button
- Position: Top-right
- Padding: 10px 10px 0 24px
- Icon: X from lucide-react
- Size: 20x20px
Responsive Behavior
-
Desktop (≥768px):
- Default modal: 486px width, centered
- Lateral panel: 400px width from right
- Padding: 24px
- Margins: 96px from edges
-
Mobile (less than 768px):
- Default modal: Full width minus 48px margin
- Lateral panel: Full width
- Full-screen: Bottom sheet style
- Padding: 16px
- Footer padding: 8px 16px
Dependencies
- react-modal: Underlying modal library
- lucide-react: X icon for close button
- styled-media-query: Responsive styling
Accessibility
- Sets
ariaHideApp={false}(should set totruein production with proper app element) - Keyboard support: ESC to close (if overlay click enabled)
- Focus trap: Keeps focus within modal
- Screen reader friendly with semantic HTML