# Confirmation

An agent asks before a risky step, then shows what was decided.

Section: Blocks / Chat
Page: https://ui.heyramzi.com/components/confirmation
Import path: `@heyramzi/ui/ai/confirmation`

## Import

```ts
import { Confirmation, ConfirmationTitle, ConfirmationState, ConfirmationActions, ConfirmationAction, type ConfirmationKind, } from "@heyramzi/ui/ai/confirmation";
```

## Usage

```svelte
<Confirmation {kind}>
  <ConfirmationTitle>Delete 3 stale views?</ConfirmationTitle>
  <ConfirmationState when="requested">
    <ConfirmationActions>
      <ConfirmationAction variant="outline" onclick={() => (kind = "rejected")}>Cancel</ConfirmationAction>
      <ConfirmationAction onclick={() => (kind = "accepted")}>Delete</ConfirmationAction>
    </ConfirmationActions>
  </ConfirmationState>
  <ConfirmationState when="accepted">Deleted 3 views.</ConfirmationState>
  <ConfirmationState when="rejected">Kept the views.</ConfirmationState>
</Confirmation>
```

## Demo

```svelte
<script lang="ts">
	import {
		Confirmation,
		ConfirmationTitle,
		ConfirmationState,
		ConfirmationActions,
		ConfirmationAction,
		type ConfirmationKind,
	} from "@heyramzi/ui/ai/confirmation";

	let kind = $state<ConfirmationKind>("requested");
</script>

<div class="stack">
	<Confirmation {kind}>
		<ConfirmationTitle>Delete 3 stale views?</ConfirmationTitle>
		<ConfirmationState when="requested">
			<p class="body">Removes the views from the workspace. This can't be undone.</p>
			<ConfirmationActions>
				<ConfirmationAction variant="outline" onclick={() => (kind = "rejected")}>
					Cancel
				</ConfirmationAction>
				<ConfirmationAction onclick={() => (kind = "accepted")}>Delete</ConfirmationAction>
			</ConfirmationActions>
		</ConfirmationState>
		<ConfirmationState when="accepted">Deleted 3 views.</ConfirmationState>
		<ConfirmationState when="rejected">Kept the views.</ConfirmationState>
	</Confirmation>

	{#if kind !== "requested"}
		<button type="button" class="reset" onclick={() => (kind = "requested")}>Reset</button>
	{/if}
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: 0.625rem;
		width: 100%;
	}
	.body {
		margin: 0;
		font-size: 0.8125rem;
		color: var(--muted-foreground);
	}
	.reset {
		align-self: flex-start;
		padding: 0.375rem 0.75rem;
		font-size: 0.75rem;
		color: var(--foreground);
		background: var(--card);
		border: 1px solid var(--border);
		border-radius: 0.5rem;
		cursor: pointer;
	}
</style>
```

## API

### Confirmation.Confirmation

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `kind` | `"idle"` \| `"requested"` \| `"accepted"` \| `"rejected"` \| `"failed"` |  | required |
| `executing` | `boolean` | `false` |  |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLElement>` from `svelte/elements`.

### Confirmation.Title

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLParagraphElement>` from `svelte/elements`.

### Confirmation.State

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `when` | `Exclude<ConfirmationKind, "idle">` |  | required. The state whose content this shows. |
| `children` | `Snippet` |  |  |

### Confirmation.Actions

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLDivElement>` from `svelte/elements`.

### Confirmation.Action

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `busyLabel` | `string` |  |  |
| `busyWhen` | `"always" \| "default" \| "never"` | `"default"` |  |
| `variant` | `"default"` \| `"outline"` \| `"ghost"` \| `"destructive"` \| `"text"` \| `"dashed"` | `"default"` |  |
| `size` | `"sm"` \| `"default"` \| `"lg"` | `"sm"` |  |
| `icon` | `boolean` |  |  |
| `ref` | `HTMLButtonElement \| HTMLAnchorElement \| null` |  |  |
| `class` | `string` |  |  |
| `disabled` | `boolean` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLButtonAttributes` from `svelte/elements`.

Every prop of `HTMLAnchorAttributes` from `svelte/elements`.
