# Shadcn Unsaved Changes

> Warning for unsaved changes when navigating away

- Type: example, free and open source (MIT)
- Component: [Alert Dialog](https://reui.io/components/alert-dialog.md)
- Page: https://reui.io/components/alert-dialog/c-alert-dialog-9
- Docs (Base UI): https://ui.shadcn.com/docs/components/base/alert-dialog.md
- Docs (Radix UI): https://ui.shadcn.com/docs/components/radix/alert-dialog.md
- MCP: `get_example("c-alert-dialog-9")`
- Registry item: https://reui.io/r/styles/base-nova/c-alert-dialog-9.json
- Uses: Alert Dialog, Button, Checkbox, Frame, Label

## Best for

An unsaved changes guard inside a Frame panel, with Stay, Discard and a do not ask again box

## Agent notes

- Nothing here detects unsaved edits; open it from your navigation guard rather than the `AlertDialogTrigger` button

## Install

```bash
npx shadcn@latest add @reui/c-alert-dialog-9
```

## About Shadcn Alert Dialog

### When to use

- Modal prompts that block the page and ask the user to answer or acknowledge
- Confirmations, permission requests and notices that a backdrop click must not close

### When not to use

- A form or settings panel that a click outside may dismiss: use [Dialog](https://reui.io/components/dialog.md) (`get_component("dialog")`)
- A status or warning shown in the page with no decision to make: use [Alert](https://reui.io/components/alert.md) (`get_component("alert")`)
- A modal task with several fields, such as a plan cancellation survey: use the [Dialog blocks](https://reui.io/blocks/application/dialog.md)

### Agent notes

- On the base twin `AlertDialogAction` is a plain `Button` that leaves the dialog open; the radix one closes it on click
- `AlertDialogTrigger` takes its button through `render` on the base twin and `asChild` on the radix twin
- `size` sm on `AlertDialogContent` sets the footer as 2 equal columns, so keep it to 2 buttons

Every ReUI item has a twin like this one; the index is https://reui.io/llms.txt. Agents with the ReUI MCP (https://reui.io/docs/mcp) get the same guidance from the getters named above.
