Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Hold Button

    Tombol tekan dan tahan untuk aksi berisiko. Isian menunjukkan progres, lepas lebih awal membatalkan, lalu event complete dipicu.

    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 {}

    Contoh

    Varian

    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

    Ukuran dan durasi

    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

    Konfirmasi penghapusan

    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

    Instalasi

    npx markasui@latest add hold-button

    Pemakaian

    <form method="POST" action="/workspace" x-data x-on:complete="$el.submit()">
        @csrf
        @method('DELETE')
        <x-markas.hold-button variant="danger" :duration="2000" hold-label="Tekan dan tahan untuk mengonfirmasi">Tahan untuk menghapus</x-markas.hold-button>
    </form>
    import { HoldButton } from "@/components/markas/HoldButton";
    
    <HoldButton
      variant="danger"
      duration={2000}
      holdLabel="Tekan dan tahan untuk mengonfirmasi"
      onComplete={deleteWorkspace}
    >
      Tahan untuk menghapus
    </HoldButton>;
    <script setup lang="ts">
    import HoldButton from "@/components/markas/HoldButton.vue";
    </script>
    
    <template>
      <HoldButton
        variant="danger"
        :duration="2000"
        hold-label="Tekan dan tahan untuk mengonfirmasi"
        @complete="deleteWorkspace"
      >
        Tahan untuk menghapus
      </HoldButton>
    </template>
    <script lang="ts">
      import HoldButton from "$lib/components/markas/HoldButton.svelte";
    </script>
    
    <HoldButton
      variant="danger"
      duration={2000}
      holdLabel="Tekan dan tahan untuk mengonfirmasi"
      oncomplete={deleteWorkspace}
    >
      Tahan untuk menghapus
    </HoldButton>
    ---
    import HoldButton from "@/components/markas/HoldButton.astro";
    ---
    
    <HoldButton
      id="hapus-workspace"
      variant="danger"
      duration={2000}
      holdLabel="Tekan dan tahan untuk mengonfirmasi"
    >
      Tahan untuk menghapus
    </HoldButton>
    
    <script>
      document
        .getElementById("hapus-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"
          holdLabel="Tekan dan tahan untuk mengonfirmasi"
          (complete)="deleteWorkspace()"
        >
          Tahan untuk menghapus
        </markas-hold-button>
      `,
    })
    export class DangerZone {
      deleteWorkspace() {}
    }

    Astro mengirim event DOM complete yang bubble dari tombol. Angular memindahkan id, aria-label, title, dan class dari markas-hold-button ke tombol di dalamnya.

    • Jalankan aksi di event complete. Klik singkat tidak melakukan apa-apa.
    • Pointer up, pointer leave, blur, atau melepas Spasi atau Enter sebelum selesai membatalkan dan isian kembali.
    • Tombol tetap data-state=“complete” sampai dilepas. Blade mengirim event DOM complete yang bubble dan butuh Alpine.js.

    Props

    NamaTipeDefaultKeterangan
    variant'primary' | 'secondary' | 'ghost' | 'danger'primaryGaya visual, sama seperti Button.
    size'sm' | 'md' | 'lg'mdTinggi 32, 40, atau 48px, sama seperti Button.
    durationnumber1500Lama tombol harus ditahan, dalam milidetik.
    holdLabelstringPress and hold to confirmPetunjuk tersembunyi yang ditautkan lewat aria-describedby.
    onComplete / @complete / oncomplete / (complete)() => void-Dipicu saat tahanan mencapai durasi penuh (React, Vue, Svelte, Angular). Blade dan Astro mengirim event DOM complete yang bubble.

    Aksesibilitas

    • Menahan Spasi atau Enter sama seperti menahan pointer, melepas tombol membatalkan.
    • holdLabel ditautkan lewat aria-describedby agar screen reader menjelaskan cara memakainya.
    • Keadaan tersedia sebagai data-state idle, holding, atau complete.
    • Isian progres tetap berjalan saat reduced motion karena membawa makna, berupa isian linear tanpa gerakan.

    Komponen terkait

    Komponen tombol lain dengan class yang sama di setiap framework.