Advanced Usage
Deep dive into advanced patterns and techniques for use-disclosable.
Promise-Based Workflows
The open() function returns a Promise that resolves when the dialog is closed. This enables clean, linear code flow:
How It Works
open()creates the dialog and returns a pending Promise- The Promise stays pending until
closeDisclosable()is called - The resolved value is passed via the
closeReasonparameter
Close Reasons
Use closeReason to signal how the dialog was closed:
Common Patterns
Confirmation Flow:
Animation Handling
Use destroyAfter to delay unmounting for exit animations:
With close/closeAll:
Multiple Dialogs
Stacking Dialogs
Replacing Dialogs
Use replace: true to replace an existing dialog:
Server Components (Next.js)
use-disclosable works with Next.js App Router:
Info
The DisclosableRoot component has "use client" directive built-in, so it
works seamlessly with Server Components.
