React Modal Component API

Modal API

Explore the API reference for the React Modal component and discover how to effectively utilize its props for customization.

CModal

jsx
import { CModal } from '@coreui/react-pro'
PropertyDefaultType
backdroptrueboolean, 'static'

Apply a backdrop on body while modal is open. 'static' keeps the modal open on a backdrop click and bounces it instead.

className-string

A string of all className you want applied to the base component.

dark6.0.0+-boolean

Flip the modal to the dark color mode, whatever the page around it uses.

defaultShow6.0.0+-boolean

The initial open state of an uncontrolled modal — read once on mount.

fullscreen-boolean, 'sm', 'md', 'lg', 'xl', '2xl'

Set modal to covers the entire user viewport.

keyboardtrueboolean

Closes the modal when escape key is pressed.

modal6.0.0+trueboolean

Open the dialog modally, taking over the page. Set it to false for a dialog that leaves the rest of the page interactive.

onClose-(() => void)

Callback fired once the component has closed.

onClosePrevented-(() => void)

Callback fired when the modal is shown, its backdrop is static and a click outside the modal or an escape key press is performed with the keyboard option set to false.

onShow-(() => void)

Callback fired when the component requests to be shown.

onShowChange6.0.0+-((show: boolean) => void)

Callback fired when the modal requests an open-state change — a dismiss gesture (Escape, backdrop click) or, in uncontrolled mode, any internal toggle. In controlled mode update show yourself, or the modal stays as it is.

scrollable-boolean

Create a scrollable modal that allows scrolling the modal body.

show6.0.0+-boolean

Control the open state. When set, the modal renders what show says and dismiss gestures only call onShowChange — nothing closes until the parent flips the prop.

size-'sm', 'lg', 'xl'

Size the component small, large, or extra large.

transitiontrueboolean

Remove animation to create modal that simply appear rather than fade in to view.

unmountOnClosetrueboolean

By default the component is unmounted after close animation, if you want to keep the component mounted set this property to false.

visibleDeprecated 6.0.0-boolean

Toggle the visibility of modal component.

Use defaultShow / show / onShowChange instead — visible is ignored when either of them is set.

CModalBody

jsx
import { CModalBody } from '@coreui/react-pro'
PropertyDefaultType
className-string

A string of all className you want applied to the base component.

CModalFooter

jsx
import { CModalFooter } from '@coreui/react-pro'
PropertyDefaultType
className-string

A string of all className you want applied to the base component.

CModalHeader

jsx
import { CModalHeader } from '@coreui/react-pro'
PropertyDefaultType
ariaCloseLabel5.13.0+-string

Sets the aria-label of the close button.

className-string

A string of all className you want applied to the base component.

closeButtontrueboolean

Add a close button component to the header.

CModalTitle

jsx
import { CModalTitle } from '@coreui/react-pro'
PropertyDefaultType
ash5(ElementType & 'symbol') | (ElementType & 'object') | (ElementType & 'h5') | (ElementType & 'slot') | (ElementType & 'style') | ... 175 more ...

Component used for the root node. Either a string to use a HTML element or a component.

className-string

A string of all className you want applied to the base component.