MinecraftButton

A pixel stone menu button that cracks every few taps, shatters into chips, and drops itself as a bobbing item you pick up to respawn it.

Preview

Props

Install

npx shadcn@latest add @evilbuttons/minecraft-button
import { Pixelify_Sans } from "next/font/google";

const pixel = Pixelify_Sans({ variable: "--font-pixel", subsets: ["latin"] });

// <html className={pixel.variable}>

Usage

import { MinecraftButton } from "@/components/evil-buttons/minecraft-button";

export function ButtonDemo() {
  return (
    <MinecraftButton
      tapsPerStage={5}
      stages={4}
      onCrack={(stage) => console.log("Crack stage", stage)}
      onBreak={() => console.log("Broken.")}
    >
      Singleplayer
    </MinecraftButton>
  );
}

Props

The component spreads native button props. onClick fires on every tap before it counts; call event.preventDefault() to skip that tap.

PropTypeDefaultDescription
childrenReact.ReactNode-Button label. Falls back to label.
labelReact.ReactNode"Singleplayer"Label used when no children are provided.
tapsPerStagenumber5Taps needed to advance one crack stage.
stagesnumber4Stages until it breaks. The button breaks after tapsPerStage * stages taps.
soundbooleantruePlay synthesized dig, crack, break, and pickup sounds (Web Audio, no files).
pickaxebooleantrueSwap the mouse cursor for a pixel pickaxe that winds up on press and strikes on release.
respawnAfternumber-Respawn automatically after this many ms. Omit to wait for the drop to be picked up.
onCrack(stage: number) => void-Fired when the crack deepens to a new stage.
onBreak() => void-Fired when the button breaks.
onRespawn() => void-Fired when the button comes back.
classNamestring-Extra classes merged onto the button.

Good to know

  • Everything snaps to a 3px texel grid.
  • The pickaxe cursor shows for mouse and pen, never touch.

Search docs

Jump to a button documentation page