CooldownButton

Get this button for GPUI

A button that locks itself behind a draining radial timer after each click to stop spam and double-submits, taunting you while you wait.

Preview

Props

Variants

Longer leash

Tune cooldown and supply your own taunts.

Install

npx shadcn@latest add @evilbuttons/cooldown-button

Usage

import { CooldownButton } from "@/components/evil-buttons/cooldown-button";

export function ButtonDemo() {
  return (
    <CooldownButton cooldown={3000} onClick={() => sendRequest()}>
      Send it
    </CooldownButton>
  );
}

Props

The component spreads any <button> HTML attributes.

PropTypeDefaultDescription
childrenReact.ReactNode-Idle label. Falls back to label.
labelReact.ReactNode"Send it"Idle label used when no children are provided.
cooldownnumber3000Lockout duration in milliseconds after each click. Set to 0 to disable the cooldown.
tauntsstring[]5 defaultsPool of messages; one is picked at random per cooldown.
showCountdownbooleantrueAppend the remaining whole seconds to the taunt while locked.
onClick(e) => void-Fires immediately on a valid click, before the cooldown begins.
classNamestring-Extra classes passed to the button.

Good to know

  • Disabled for the whole cooldown, so no double submits.

Search docs

Jump to a button documentation page