Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Hold Button

    Press-and-hold button for risky actions. A fill tracks progress, releasing early cancels, and a complete event fires.

    Press and hold to confirm
    Press and hold to confirm
    Press and hold to confirm
    Press and hold to confirm
    Press and hold to confirm
    <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>
    import { Component } from "@angular/core";
    import { HoldButton } from "./markas/hold-button.component";
    
    @Component({
      selector: "markas-example",
      imports: [HoldButton],
      template: `
        <div class="flex justify-center">
          <markas-hold-button variant="danger">Hold to delete</markas-hold-button>
        </div>
      `,
    })
    export default class HoldButtonExample {}

    Examples

    Variants

    Press and hold to confirm Press and hold to confirm Press and hold to confirm Press and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirmPress and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirmPress and hold to confirm
    Press and hold to confirm Press and hold to confirm Press and hold to confirm Press and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirmPress and hold to confirm

    Sizes and durations

    Press and hold to confirm Press and hold to confirm Press and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirm
    Press and hold to confirm Press and hold to confirm Press and hold to confirm
    Press and hold to confirmPress and hold to confirmPress and hold to confirm

    Confirm a deletion

    Delete workspace

    This removes 12 projects and 48 members. It cannot be undone.

    Press and hold to confirm

    Delete workspace

    This removes 12 projects and 48 members. It cannot be undone.

    Press and hold to confirm

    Delete workspace

    This removes 12 projects and 48 members. It cannot be undone.

    Press and hold to confirm

    Delete workspace

    This removes 12 projects and 48 members. It cannot be undone.

    Press and hold to confirm

    Delete workspace

    This removes 12 projects and 48 members. It cannot be undone.

    Press and hold to confirm

    Installation

    npx markasui@latest add hold-button

    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 complete DOM event and needs Alpine.js.

    Props

    NameTypeDefaultDescription
    variant'primary' | 'secondary' | 'ghost' | 'danger'primaryVisual style, the same set as Button.
    size'sm' | 'md' | 'lg'mdHeight 32, 40, or 48px, the same as Button.
    durationnumber1500How long the button must be held, in milliseconds.
    holdLabelstringPress and hold to confirmHidden 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.