Press-and-hold button for risky actions. A fill tracks progress, releasing early cancels, and a complete event fires.
<div class="flex justify-center">
<x-markas.hold-button variant="danger">Hold to delete</x-markas.hold-button>
</div>import { HoldButton } from "@/components/markas/HoldButton";
export default function HoldButtonExample() {
return (
<div className="flex justify-center">
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>
);
}<script setup lang="ts">
import HoldButton from "@/components/markas/HoldButton.vue";
</script>
<template>
<div class="flex justify-center">
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>
</template><script lang="ts">
import HoldButton from "$lib/components/markas/HoldButton.svelte";
</script>
<div class="flex justify-center">
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>---
import HoldButton from "@/components/markas/HoldButton.astro";
---
<div class="flex justify-center">
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>Examples
Variants
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.hold-button>Hold to publish</x-markas.hold-button>
<x-markas.hold-button variant="secondary">Hold to archive</x-markas.hold-button>
<x-markas.hold-button variant="ghost">Hold to reset</x-markas.hold-button>
<x-markas.hold-button variant="danger">Hold to delete</x-markas.hold-button>
</div>import { HoldButton } from "@/components/markas/HoldButton";
export default function Example() {
return (
<div className="flex flex-wrap items-center justify-center gap-3">
<HoldButton>Hold to publish</HoldButton>
<HoldButton variant="secondary">Hold to archive</HoldButton>
<HoldButton variant="ghost">Hold to reset</HoldButton>
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>
);
}<script setup lang="ts">
import HoldButton from "@/components/markas/HoldButton.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton>Hold to publish</HoldButton>
<HoldButton variant="secondary">Hold to archive</HoldButton>
<HoldButton variant="ghost">Hold to reset</HoldButton>
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>
</template><script lang="ts">
import HoldButton from "$lib/components/markas/HoldButton.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton>Hold to publish</HoldButton>
<HoldButton variant="secondary">Hold to archive</HoldButton>
<HoldButton variant="ghost">Hold to reset</HoldButton>
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>---
import HoldButton from "@/components/markas/HoldButton.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton>Hold to publish</HoldButton>
<HoldButton variant="secondary">Hold to archive</HoldButton>
<HoldButton variant="ghost">Hold to reset</HoldButton>
<HoldButton variant="danger">Hold to delete</HoldButton>
</div>Sizes and durations
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.hold-button size="sm" :duration="1000">Hold 1s</x-markas.hold-button>
<x-markas.hold-button>Hold 1.5s</x-markas.hold-button>
<x-markas.hold-button size="lg" :duration="3000">Hold 3s</x-markas.hold-button>
</div><script setup lang="ts">
import HoldButton from "@/components/markas/HoldButton.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton size="sm" :duration="1000">Hold 1s</HoldButton>
<HoldButton>Hold 1.5s</HoldButton>
<HoldButton size="lg" :duration="3000">Hold 3s</HoldButton>
</div>
</template><script lang="ts">
import HoldButton from "$lib/components/markas/HoldButton.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton size="sm" duration={1000}>Hold 1s</HoldButton>
<HoldButton>Hold 1.5s</HoldButton>
<HoldButton size="lg" duration={3000}>Hold 3s</HoldButton>
</div>---
import HoldButton from "@/components/markas/HoldButton.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3">
<HoldButton size="sm" duration={1000}>Hold 1s</HoldButton>
<HoldButton>Hold 1.5s</HoldButton>
<HoldButton size="lg" duration={3000}>Hold 3s</HoldButton>
</div>Confirm a deletion
Delete workspace
This removes 12 projects and 48 members. It cannot be undone.
Delete workspace
This removes 12 projects and 48 members. It cannot be undone.
Delete workspace
This removes 12 projects and 48 members. It cannot be undone.
Delete workspace
This removes 12 projects and 48 members. It cannot be undone.
Delete workspace
This removes 12 projects and 48 members. It cannot be undone.
<div class="grid gap-4 rounded-xl border border-line bg-surface p-6">
<div class="grid gap-1">
<p class="text-base font-semibold text-ink">Delete workspace</p>
<p class="text-sm text-muted">This removes 12 projects and 48 members. It cannot be undone.</p>
</div>
<div class="flex flex-wrap justify-end gap-2">
<x-markas.button variant="secondary">Cancel</x-markas.button>
<x-markas.hold-button variant="danger" :duration="2000">Hold to delete</x-markas.hold-button>
</div>
</div>Installation
npx markasui@latest add hold-buttonpnpm dlx markasui@latest add hold-buttonyarn dlx markasui@latest add hold-buttonbunx --bun markasui@latest add hold-button- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/hold-button.blade.php.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/HoldButton.tsx.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/HoldButton.vue.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/HoldButton.svelte.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/HoldButton.astro.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/hold-button.component.ts.
Usage
<form method="POST" action="/workspace" x-data x-on:complete="$el.submit()">
@csrf
@method('DELETE')
<x-markas.hold-button variant="danger" :duration="2000">Hold to delete</x-markas.hold-button>
</form>import { HoldButton } from "@/components/markas/HoldButton";
<HoldButton variant="danger" duration={2000} onComplete={deleteWorkspace}>
Hold to delete
</HoldButton>;<script setup lang="ts">
import HoldButton from "@/components/markas/HoldButton.vue";
</script>
<template>
<HoldButton variant="danger" :duration="2000" @complete="deleteWorkspace">
Hold to delete
</HoldButton>
</template><script lang="ts">
import HoldButton from "$lib/components/markas/HoldButton.svelte";
</script>
<HoldButton variant="danger" duration={2000} oncomplete={deleteWorkspace}>
Hold to delete
</HoldButton>---
import HoldButton from "@/components/markas/HoldButton.astro";
---
<HoldButton id="delete-workspace" variant="danger" duration={2000}>
Hold to delete
</HoldButton>
<script>
document
.getElementById("delete-workspace")
?.addEventListener("complete", () => deleteWorkspace());
</script>import { Component } from "@angular/core";
import { HoldButton } from "./markas/hold-button.component";
@Component({
selector: "app-dangerzone",
imports: [HoldButton],
template: `
<markas-hold-button
variant="danger"
[duration]="2000"
(complete)="deleteWorkspace()"
>
Hold to delete
</markas-hold-button>
`,
})
export class DangerZone {
deleteWorkspace() {}
}Astro dispatches a bubbling complete DOM event from the button. Angular moves id, aria-label, title, and class from markas-hold-button to the inner button.
- Run the action in the complete event. A short click does nothing.
- Pointer up, pointer leave, blur, or releasing Space or Enter before the end cancels and the fill slides back.
- The button keeps data-state=“complete” until it is released. Blade dispatches a bubbling
completeDOM event and needs Alpine.js.
Props
| Name | Type | Default | Description |
|---|---|---|---|
variant | 'primary' | 'secondary' | 'ghost' | 'danger' | primary | Visual style, the same set as Button. |
size | 'sm' | 'md' | 'lg' | md | Height 32, 40, or 48px, the same as Button. |
duration | number | 1500 | How long the button must be held, in milliseconds. |
holdLabel | string | Press and hold to confirm | Hidden hint linked with aria-describedby. |
onComplete / @complete / oncomplete / (complete) | () => void | - | Fires once the hold reaches the full duration (React, Vue, Svelte, Angular). Blade and Astro dispatch a bubbling complete DOM event. |
Accessibility
- Holding Space or Enter works like holding the pointer, releasing the key cancels.
- holdLabel is linked with aria-describedby so screen readers explain the gesture.
- The state is exposed as data-state idle, holding, or complete.
- The progress fill keeps running with reduced motion because it carries meaning, it is a linear fill without movement.
Related components
More buttons components with the same classes in every framework.
- Copy ButtonCopies a string to the clipboard. The copy icon turns into an animated check mark and a live region says Copied.
- Flip ButtonButton that flips like a card on hover and keyboard focus to reveal a second line on the back.
- GitHub Stars ButtonLink to a GitHub repository with the GitHub mark and a star count that counts up when it scrolls into view. No fetch.
- Ripple ButtonButton that sends a ripple out from the click point, or from the center when pressed with the keyboard.
- Shimmer ButtonButton with a soft sheen that sweeps across it on a loop. The loop pauses off screen and stops with reduced motion.