Action dialog

GitHub

Route-backed dialog that can confirm closing when a nested form has unsaved changes.

Installation

bash
pnpm dlx shadcn@latest add @cs/action-dialog

Usage

tsx
import { ActionDialog } from "@/components/cs/action-dialog";
tsx
<ActionDialog
  labels={{
    confirmExit: "Leave this page?",
    areYouSure: "Your unsaved changes will be lost.",
    cancel: "Stay",
    exit: "Leave",
  }}
>
  <p>Dialog content</p>
</ActionDialog>

API Reference

useActionDialogContext

Returns the closest ActionDialog state bridge for nested forms.

ActionDialog

Dialog that confirms closing when a nested form has unsaved changes.

Props

NameTypeDefaultDescription
children *React.ReactNode-Dialog contents, usually a Form.
classNameDialogContentProps["className"]-Additional dialog content classes.
labelsActionDialogLabels-Text displayed by the close confirmation dialog.
positionDialogContentProps["position"]-Dialog placement on the screen.
preventCloseboolean-Prevents closing the dialog. Changed nested forms enable this automatically.
sizeDialogContentProps["size"]-Maximum dialog width.