Skip to content

Hold to confirm

A button that must be held for a moment before it acts. For actions that are hard to undo, without a second dialog.

CSS + mian.js JSON Markdown Registry item

Delete

Installation

Everything ships in one stylesheet and one small script. There is nothing to import per component.

<link rel="stylesheet" href="https://mian.ro/dist/mian.css">
<script src="https://mian.ro/dist/mian.js" defer></script>

Prefer to own the files? /r/hold-button.json is a registry item with this component's CSS and example markup, ready to copy into your project with any tool that reads the open registry-item format.

Class reference

Class / attributeDescription
mn-holdOn an mn-btn, with data-mn-hold. A fill sweeps across while it is held.
--_holdHow long to hold. Default 1200ms.
data-mn-hold-doneText to show once it has fired.
mn:confirmThe event to listen for. A plain click does nothing.

Accessibility

  • Works with a pointer, and with Space or Enter held down.
  • Say “hold” in the label, so the behaviour is not a surprise.
  • Releasing early cancels; nothing happens on a quick click or tap.
  • Still offer undo where you can: holding prevents accidents, it does not replace recovery.
Choose a noodle

Minimal

Flat

Pixel

Linear

Thin

Glass

Textured

Bold

Elegant

Rounded

On this page