Modal
A dialog overlay that displays content in a floating container above the page with configurable animations, positions, and sizes.
Import
Usage
Examples
Size variants
Radius
Position
Animation presets
Custom width and height
Backdrop behavior
ESC key behavior
Custom overlay
Props
| Prop | Type | Default | Description |
|---|---|---|---|
isOpen | boolean | None | Controls modal visibility (required) |
onClose | () => void | None | Callback when modal closes |
children | ReactNode | None | Modal content (required) |
size | "sm" | "md" | "lg" | "xl" | "full" | "md"* | Size scale |
position | "center" | "top" | "bottom" | "center"* | Vertical placement |
radius | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "full" | "lg"* | Corner rounding |
animated | boolean | true* | Enable/disable animations |
width | string | None | Custom width override |
height | string | None | Custom height override |
closeOnBackdropClick | boolean | true* | Close when clicking backdrop |
closeOnEscape | boolean | true* | Close when pressing ESC key |
overlayClassName | string | None | Extra classes for overlay |
contentClassName | string | None | Extra classes for content container |
className | string | None | Extra classes for modal container |
* Falls back through Global Configuration if not set. See below.
Global Configuration
Modal reads defaults from four places, in this order of precedence:
- Instance prop: set directly on
<Modal /> - Component config:
components.modalin yourashee.config - Theme default:
defaultRadiusin yourashee.config - Built-in fallback: component's internal default values
Component config
Built-in fallbacks
Accessibility
- Renders a native dialog role with
aria-modal="true" - Automatically locks body scroll when open
- Focus management with focus trapping
- ESC key support for closing (configurable)
- Backdrop click support for closing (configurable)
- Implements
focus-visibleoutlines for keyboard navigation
Notes
- Body Scroll Lock: When the modal is open, scrolling on the body is automatically disabled to prevent background scrolling.
- Animation: The modal uses
popanimation by default with a 200ms duration. Disable withanimated={false}. - Custom Sizing: Use
widthandheightprops to override the default size-based values. - Position: The
topposition places the modal near the top with margin, whilebottomplaces it near the bottom. - Focus Management: Focus is automatically trapped inside the modal for accessibility.
- Backdrop: The backdrop overlay is a
buttonelement that can be clicked to close the modal whencloseOnBackdropClickis enabled.