# Alert dialog: Detached triggers

> Create a handle with `createAlertDialogHandle()` to share one dialog between many triggers. Each trigger passes its own `payload`, which the dialog reads through a render function.

Example: https://hextaui.com/docs/alert-dialog/examples/detached-triggers
Component docs: https://hextaui.com/docs/alert-dialog.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/alert-dialog-detached-triggers.json
```

This adds `components/examples/alert-dialog/detached-triggers.tsx` with the Alert dialog component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/alert-dialog/detached-triggers.tsx"
"use client"

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
  createAlertDialogHandle,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"

const removeMember = createAlertDialogHandle<{ name: string }>()

export function AlertDialogDetachedTriggers() {
  return (
    <div className="flex flex-wrap gap-2">
      {["Olivia", "Liam"].map((name) => (
        <AlertDialogTrigger
          key={name}
          handle={removeMember}
          payload={{ name }}
          render={<Button variant="outline" />}
        >
          Remove {name}
        </AlertDialogTrigger>
      ))}
      <AlertDialog handle={removeMember}>
        {({ payload }) => (
          <AlertDialogContent size="sm">
            <AlertDialogHeader>
              <AlertDialogTitle>Remove {payload?.name}?</AlertDialogTitle>
              <AlertDialogDescription>
                They’ll lose access to this workspace.
              </AlertDialogDescription>
            </AlertDialogHeader>
            <AlertDialogFooter>
              <AlertDialogCancel>Cancel</AlertDialogCancel>
              <AlertDialogAction variant="destructive">
                Remove
              </AlertDialogAction>
            </AlertDialogFooter>
          </AlertDialogContent>
        )}
      </AlertDialog>
    </div>
  )
}
```

## Props in this example

### AlertDialog

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `handle` | `AlertDialogHandle<Payload>` | – | Connects detached triggers. |

### AlertDialogTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `handle` | `AlertDialogHandle<Payload>` | – |  |
| `payload` | `Payload` | – | Passed to the dialog’s render function. |
| `render` | `ReactElement \| (props, state) => ReactElement` | `<button>` |  |

### AlertDialogContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "sm"` | `"default"` |  |

### AlertDialogAction

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `ButtonVariant` | `"default"` |  |

## More Alert dialog examples

- [Async action](https://hextaui.com/docs/alert-dialog/examples/async-action.md)
- [Media](https://hextaui.com/docs/alert-dialog/examples/media.md)
- [Small](https://hextaui.com/docs/alert-dialog/examples/small.md)
- [Controlled](https://hextaui.com/docs/alert-dialog/examples/controlled.md)
- [Nested](https://hextaui.com/docs/alert-dialog/examples/nested.md)
- [Long content](https://hextaui.com/docs/alert-dialog/examples/long-content.md)
- [Right to left](https://hextaui.com/docs/alert-dialog/examples/rtl.md)
