# Dialog

Confirmation dialog with OK/Cancel actions



<ComponentPreview base="ink" name="dialog-demo" />

Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @termcn/dialog
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource base="ink" name="dialog" title="components/ui/dialog.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

Usage [#usage]

```tsx
import { Dialog } from "@/components/ui/dialog";
```

```tsx
<Dialog
  isOpen={true}
  title="Save changes?"
  onConfirm={() => save()}
  onCancel={() => discard()}
>
  <Text>You have unsaved changes. Would you like to save them?</Text>
</Dialog>
```

API Reference [#api-reference]

Dialog [#dialog]

| Prop           | Type                    | Default     |
| -------------- | ----------------------- | ----------- |
| `title`        | `string`                | -           |
| `children`     | `ReactNode`             | `required`  |
| `confirmLabel` | `string`                | `"OK"`      |
| `cancelLabel`  | `string`                | `"Cancel"`  |
| `onConfirm`    | `() => void`            | -           |
| `onCancel`     | `() => void`            | -           |
| `variant`      | `"default" \| "danger"` | `"default"` |
| `isOpen`       | `boolean`               | `false`     |
