LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Interaction feedback

Hold to confirm

Also called press and hold or long press to confirm

A button you press and hold for a moment, with a fill that shows progress, used to confirm a destructive or important action.

import { useState, type KeyboardEvent } from 'react';
import { animate, motion, useMotionValue } from 'motion/react';

const HOLD_SECONDS = 1.5;
const DRAIN_SECONDS = 0.3;

const isHoldKey = (event: KeyboardEvent) =>
  event.key === ' ' || event.key === 'Enter';

export function HoldToDeleteButton({ onConfirm }: { onConfirm: () => void }) {
  const progress = useMotionValue(0);
  const [deleted, setDeleted] = useState(false);

  function start() {
    // Resume from wherever a drain left off.
    animate(progress, 1, {
      duration: HOLD_SECONDS * (1 - progress.get()),
      ease: 'linear',
      onComplete: () => {
        setDeleted(true);
        onConfirm();
      }
    });
  }

  function cancel() {
    if (progress.get() === 1) return;
    // Animating the value again stops the fill before onComplete runs.
    animate(progress, 0, { duration: DRAIN_SECONDS, ease: 'easeOut' });
  }

  if (deleted) return <p role='status'>✓ Project deleted</p>;

  return (
    <button
      type='button'
      onPointerDown={start}
      onPointerUp={cancel}
      onPointerLeave={cancel}
      onPointerCancel={cancel}
      onKeyDown={(event) => {
        if (!isHoldKey(event) || event.repeat) return;
        event.preventDefault();
        start();
      }}
      onKeyUp={(event) => isHoldKey(event) && cancel()}
      className='relative touch-none overflow-hidden rounded-lg bg-red-500 px-5 py-2.5 text-sm font-medium text-white select-none'
    >
      <motion.span
        aria-hidden
        style={{ scaleX: progress }}
        className='absolute inset-0 origin-left bg-red-700'
      />
      <span className='relative'>Hold to delete</span>
    </button>
  );
}
Turn the "Delete project" button into a hold-to-confirm button labeled "Hold to delete": while the pointer or the Space or Enter key is held, fill it from left to right in red over 1.5 seconds (linear), and delete only when the fill completes. If released early, drain the fill over 300ms and do nothing. After deleting, show "Project deleted" with a check icon.

Paste into Layerwise or any AI coding tool.

What is Hold to confirm?

A hold-to-confirm button asks for a deliberate press instead of a quick click. While you hold it, a fill sweeps across the button. Let go early and the fill drains away with nothing done; hold until the fill completes and the action runs.

It is a lighter alternative to an "Are you sure?" dialog for actions like deleting a project, sending money, or ending a call. A hold of about one to two seconds is long enough to prevent accidents and short enough not to feel like a chore.

Say "Hold to delete" in the label, since few people expect to hold a button. Make it work from the keyboard by starting on keydown of Space or Enter and cancelling on keyup. Holding can be hard for people with limited motor control, so an undo option afterward is a good companion.

Related terms

All terms

Press feedback

A quick visual response, usually a slight shrink, that shows a button registered the press the moment a finger or mouse button goes down.

Progress bar

A horizontal bar that fills from left to right to show how much of a task is done, or slides in a loop while the total is still unknown.

Undo

A way to reverse an action right after doing it, often a toast with an Undo button that appears after deleting or archiving something.

Micro-interaction

A small moment of feedback around a single action, like a heart that bursts when tapped or a copy icon that turns into a checkmark.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit