Castle logo

CASTLE UI

Search

K

useDisclosure is a custom hook used to help handle common open, close, or toggle scenarios. It can be used to control feedback component such as Modal, AlertDialog, Drawer, etc.

This is an re-export of the useDisclosure hook from ChakraUI, see here for more information

Import

import { useDisclosure, Text } from '@passfort/castle'

Copy

Return value

The useDisclosure hook returns an object with the following fields:

NameTypeDefaultDescription
isOpenbooleanfalseIf true, it sets the controlled component to its visible state.
onClosefunctionCallback function to set a falsy value for the isOpen parameter.
onOpenfunctionCallback function to set a truthy value for the isOpen parameter.
onTogglefunctionCallback function to toggle the value of the isOpen parameter.

Usage

Copy

live example

Contents