useDisclosure

useDisclosure is a custom hook that helps handle common open/close or toggle scenarios. It can be used to control components such as Modal, Dialog, Drawer, etc.

Usage

import { useDisclosure } from "@yamada-ui/react"
const { open, onOpen, onClose, onToggle } = useDisclosure()

Using Callback Functions

To use callback functions, assign a function to onOpen or onClose. This is useful for executing APIs or other logic before opening components such as Modal.

By default, the callback functions are executed before onOpen or onClose. If you want the callbacks to be executed after onOpen or onClose, set the timing option to "after".