driftkit
ComponentsButton

Button

Motion-first button component with spring physics and smooth transitions. Features loading states, success states, and multiple variants.

Buttons

Installation

Copy and paste

Copy the component source code and paste it into your project.

import { Button } from "driftkit";

Props

NameTypeRequiredDescription
variant"default" | "secondary" | "ghost" | "destructive"NoVisual style variant. Default has dark background, secondary is lighter, ghost is transparent, destructive is red.
size"sm" | "md" | "lg"NoButton size affecting padding and text size.
loadingbooleanNoShows loading spinner and 'Loading...' text. Button becomes disabled while loading.
successbooleanNoShows success checkmark and 'Done' text. Use after successful form submission.
disabledbooleanNoDisables the button and reduces opacity. Prevents interactions.
childrenReactNodeYesButton content - text, icons, or other elements.
🎮

Playground

Tune spring physics for this component

Live Preview

Click me

Spring Physics

300
30
1

Generated Code

const springConfig = {
  "type": "spring",
  "stiffness": 300,
  "damping": 30,
  "mass": 1
};

// Basic hover animation
<motion.div
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
  transition={springConfig}
>
  <Button />
</motion.div>

// Advanced with custom animations
<motion.div
  animate={{ 
    scale: [1, 1.02, 1],
    y: [0, -4, 0]
  }}
  transition={{
    ...springConfig,
    repeat: Infinity,
    repeatDelay: 2
  }}
>
  <Button />
</motion.div>
Stiffness: Controls animation speed. Higher values create snappier animations.
Damping: Controls resistance to motion. Lower values create more bounce and overshoot.
Mass: Controls the perceived weight. Higher values make animations slower with more momentum.

Source Code

View the source code on GitHub to see the full implementation.

View on GitHub