Manages open/close state and associated data for a fixed set of named dialogs.
Array of all dialog keys. Used to initialise the state shape.
Closes from and opens to with the provided data (or from's current data if no data is provided). Useful for multi-step confirm → progress flows.
from
to
type Modals = { delete: { id: string }; create: undefined };const modals = useDialogState<Modals>(["delete", "create"]);modals.open("delete", { id: "abc" });modals.isOpen("delete"); // truemodals.getData("delete"); // { id: "abc" }modals.transition("delete", "create");modals.close("create"); Copy
type Modals = { delete: { id: string }; create: undefined };const modals = useDialogState<Modals>(["delete", "create"]);modals.open("delete", { id: "abc" });modals.isOpen("delete"); // truemodals.getData("delete"); // { id: "abc" }modals.transition("delete", "create");modals.close("create");
Manages open/close state and associated data for a fixed set of named dialogs.