Button

A versatile button component with customizable variants and click sound effects.

Mihir (OPM)

Written by Mihir (OPM)

Click It!

The Button component provides customizable styles and click sound feedback. It supports multiple variants and responds to user interactions with smooth animations and sound effects.

Installation

Add the /sound/click.wav and /sound/click-release.wav files in public folder.

Examples

Click It!

Props

PropTypeDescriptionDefault
variantstringButton style variant (clicky, silent, submit).clicky
isPressedbooleanState indicating if the button is pressed.false
volumenumberVolume for click sounds (0 to 1).1
classNamestringAdditional CSS classes.-
disabledbooleanDisables the button if true.false

Basic Usage

import Button from "@/components/button";
 
export default function Example() {
  return (
    <Button variant="clicky" volume={0.5}>
      Click Me
    </Button>
  );
}

Button Variants

  • clicky: Provides a tactile feedback animation and sound on press.
  • silent: A quieter button style with hover effects but no click sounds.
  • submit: A generic button without sound effects or special animations.

Sound Effects

The Button component includes customizable click sounds, providing a more interactive experience. Adjust the volume prop to control the sound level.

Compound Variants

  • clicky with isPressed: true: Adds depth effect using translate and thicker borders.
  • clicky with isPressed: false: Uses larger border sizes for an unpressed state.