Skip to content
synccn

Hold Button

New

Press and hold to confirm a risky action.

Press and hold, or hold Space. Let go early to cancel.

Playground

Change the props and copy the code. The controls come from the component's TypeScript types.

Props

duration1500
variant
import { HoldButton } from "@/components/ui/loaders";<HoldButton>Hold to delete</HoldButton>

Installation

$ pnpm dlx shadcn@latest add @synccn/hold-button

First time in this project? Connect synccn with one command.

Usage

import { HoldButton } from "@/components/ui/loaders";<HoldButton onConfirm={remove}>Hold to delete</HoldButton>

API reference

Generated from the component's TypeScript types, so it always matches the code.

HoldButton

Button that has to be held to confirm a risky action. Releasing early cancels. Keyboard users hold Space or Enter.

  • duration
    number

    Default 1500

    Milliseconds the button must be held.

  • onConfirm
    () => void

    Called once the hold completes.

  • variant
    "destructive" | "default"

    Default "destructive"

    Colour of the fill.

  • children
    React.ReactNode

    Default "Hold to delete"

    Content to render.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Keyboard

  • SpaceorEnterHold to confirm; release early to cancel

Accessibility

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: status
  • ARIA attributes: aria-label
  • Keys handled: Enter, Space
  • Respects the reduced motion setting
  • Announces changes to screen readers