Skip to main content
Version: 4.xx.xx


The useModal hook helps you manage the Ant Design Modal component.

const { show, close, modalProps } = useModal();

You can use the show and close props to control the modal visibility. You have to descturt modalProps to the <Modal/> component.


Let's see an example:

import { useModal } from "@refinedev/antd";
import { Modal, Button } from "antd";

export const PostList: React.FC = () => {
const { show, modalProps } = useModal();

return (
<Button onClick={show}>Show Modal</Button>
<Modal {...modalProps}>
<p>Modal Content</p>

Here, we show a button somewhere on the page and use show on it's onClick callback to trigger opening of the <Modal>. When the user clicks on the button, the <Modal> appears.

API Reference


Return Value

showReturns the visibility state of the Modal() => void
closeA function that can open the modal() => void
modalPropsSpecify a function that can close the modal() => void