Skip to content

Modal

The Modal component provides a way to display content in a layer that sits above the rest of the page content. It's commonly used for confirmation dialogs, message boxes, and other content that should temporarily block interactions with the main view.

Import

import { Modal } from "@cfa/react-core";

Live Editor

Examples

Custom Styling

You can customize the modal’s appearance using CSS classes or inline styles:

The Modal component comes with several content-specific components that help structure the modal according to Design System guidelines. These components include:

  • Modal.Content - Container for modal content
  • Modal.Title - Title component with proper styling
  • Modal.Footer - Footer component for action buttons
  • Modal.CloseButton - Pre-styled close button

These content components are optional and the Modal can be used without them for a fully customizable solution. Using the components like Title/Content will have all styles applied aside from the layout and spacing styles.

Dismissable Modal

A modal that can be dismissed by clicking outside. When using the Modal.Overlay, this prop needs to be added to the Overlay and not the Dialog.

Controlled Modal

A modal whose open state is controlled by the parent component.

Fullscreen Modal

A modal that takes up the entire viewport.

Custom Overlay

The Modal.Overlay provides a way for you to customize the Overlay itself, a common use case might be to add some z-index if you are seeing conflicts in your app. Generally you should not need to use this component.

Keep in mind that isDismissable and isKeyboardDismissDisabled will have to be used on the Overlay in this scenario.

Props

Visit the Documentation Site for the full list of props.

NameTypeDefaultDescription
defaultOpenboolean-Whether the overlay is open by default (uncontrolled).
isOpenboolean-Whether the overlay is open by default (controlled).
onOpenChange(isOpen: boolean) => void-Handler that is called when the overlay's open state changes.