# Hold to confirm

Press and hold to confirm a destructive action.

Section: Components / Actions
Page: https://ui.heyramzi.com/components/hold-to-confirm
Import path: `@heyramzi/ui/components/hold-to-confirm`

## Import

```ts
import { HoldToConfirm } from "@heyramzi/ui/components/hold-to-confirm";
```

## Usage

```svelte
<HoldToConfirm onConfirm={() => (deleted = true)}>
  {#snippet idle()}Hold to delete{/snippet}
  {#snippet holding()}Keep holding{/snippet}
</HoldToConfirm>
```

## Demo

```svelte
<script lang="ts">
	import { HoldToConfirm } from "@heyramzi/ui/components/hold-to-confirm";

	let deleted = $state(false);
</script>

<div class="flex flex-col items-center gap-3">
	<HoldToConfirm onConfirm={() => (deleted = true)}>
		{#snippet idle()}Hold to delete{/snippet}
		{#snippet holding()}Keep holding{/snippet}
	</HoldToConfirm>
	{#if deleted}
		<p class="text-sm text-muted-foreground">Deleted.</p>
	{/if}
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `duration` | `number` | `800` |  |
| `onConfirm` | `() => void` |  | required |
| `disabled` | `boolean` | `false` |  |
| `variant` | `"default"` \| `"outline"` \| `"ghost"` \| `"destructive"` \| `"text"` \| `"dashed"` | `"destructive"` | Uses the button recipe so call sites stop drawing their own. `variant: null` opts out, for a caller that really is a menu row. |
| `size` | `"sm"` \| `"default"` \| `"lg"` | `"default"` |  |
| `icon` | `boolean` | `false` | Square, for a glyph with no label. Mirrors `Button`. |
| `class` | `string` | `""` |  |
| `idle` | `Snippet` |  | required |
| `holding` | `Snippet` |  | required |
| `confirmPrompt` | `string` | `"Press again to confirm"` | Read out when a screen reader's activate arms the button. Translate at the call site. |

Every prop of `HTMLButtonAttributes` from `svelte/elements`, except `class`.
