Skip to Content
⭐️ Leave a star →
HooksuseDisclosure

useDisclosure

Manages a boolean open / close state with stable open, close, and toggle handlers. Use it for modals, drawers, dropdowns, accordions — anything with a binary open state that doesn’t need to be controlled from the outside.

import { useDisclosure } from '@wire-ui/react' function ExampleModal() { const { isOpen, open, close, toggle } = useDisclosure({ defaultOpen: false, onOpenChange: (next) => console.log('open changed:', next), }) return ( <> <button onClick={open}>Open</button> {isOpen && ( <div role="dialog"> <button onClick={close}>Close</button> </div> )} </> ) }

Options

OptionTypeDefaultDescription
defaultOpenbooleanfalseInitial open state.
onOpenChange(open: boolean) => voidCalled whenever the open state changes.

Returns

KeyTypeDescription
isOpenbooleanCurrent open state.
open() => voidSets the state to true.
close() => voidSets the state to false.
toggle() => voidFlips the current state.
setOpen(value: boolean) => voidSets the state directly.
Last updated on

MIT License © 2026 wire-ui

useDisclosure – Wire UI