www/docs/components/modal.mdx
import ModalStatic from '!!raw-loader!../examples/Modal/Static'; import ModalBasic from '!!raw-loader!../examples/Modal/Basic'; import ModalStaticBackdrop from '!!raw-loader!../examples/Modal/StaticBackdrop'; import ModalDefaultSizing from '!!raw-loader!../examples/Modal/DefaultSizing'; import ModalFullScreen from '!!raw-loader!../examples/Modal/FullScreen'; import ModalCustomSizing from '!!raw-loader!../examples/Modal/CustomSizing'; import ModalVerticallyCentered from '!!raw-loader!../examples/Modal/VerticallyCentered'; import ModalWithoutAnimation from '!!raw-loader!../examples/Modal/WithoutAnimation'; import ModalGrid from '!!raw-loader!../examples/Modal/Grid'; import ModalFocus from '!!raw-loader!../examples/Modal/Focus';
<body> so that modal content scrolls instead.@restart/ui library can support them if
you're willing.autoFocus works in Modals because React handles the implementation.Below is a <em>static</em> modal dialog (without the positioning) to demonstrate the look and feel of the Modal.
<CodeBlock language="jsx" live> {ModalStatic} </CodeBlock>A modal with header, body, and set of actions in the footer. Use <Modal/> in combination with
other components to show or hide your Modal. The <Modal/> Component comes with a few convenient
"sub components": <Modal.Header/>, <Modal.Title/>, <Modal.Body/>, and <Modal.Footer/>,
which you can use to build the Modal content.
When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it.
<CodeBlock language="jsx" live> {ModalStaticBackdrop} </CodeBlock>A Modal can also be without an animation. For that set the animation prop to false.
:::info Additional Import Options
The Modal Header, Title, Body, and Footer components are available as static properties the <Modal/>
component, but you can also, import them directly like: require("react-bootstrap/ModalHeader").
:::
You can vertically center a modal by passing the centered prop.
You can use grid layouts within a model using regular grid components inside the modal content.
<CodeBlock language="jsx" live noInline> {ModalGrid} </CodeBlock>You can focus on an element inside the modal using autoFocus attribute on the element.
You can specify a Bootstrap large or small modal by using the size prop.
You can use the fullscreen prop to make the modal fullscreen. Specifying a breakpoint will
only set the modal as fullscreen below the breakpoint size.
You can apply custom css to the modal dialog div using the dialogClassName prop. Example
is using a custom css class with width set to 90%.