Skip to Content
DocumentationuseBeforeClose

useBeforeClose

Modals can prevent themselves from closing by using useBeforeClose. If the provided callback returns false the modal will not close.

import { useBeforeClose } from "@/components/ui/modal"; export default function PreventingClose() { const [canClose, setCanClose] = useState(true); useBeforeClose(() => { return canClose }); }

Last updated on