Back to ButtonsYou are on Liquid Button.

Liquid Button

A button that fills with liquid from the bottom on hover.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
liquid-button.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/liquid-button.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/liquid-button.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
liquid-button.tsx
"use client";

import * as React from "react";
import { motion, type HTMLMotionProps, type Transition } from "motion/react";
import { cn } from "@/lib/utils";
import {
  pressSpring,
  useReduceMotion,
  useTempoTransition,
} from "./motion";

export type LiquidButtonProps = HTMLMotionProps<"button"> & {
  delay?: string;
  fillHeight?: string;
  hoverScale?: number;
  tapScale?: number;
  transition?: Transition;
};

export function LiquidButton({
  delay = "0.3s",
  fillHeight = "3px",
  hoverScale = 1,
  tapScale = 0.97,
  transition,
  className,
  children,
  ...props
}: LiquidButtonProps) {
  const reduce = useReduceMotion();
  const spring = useTempoTransition(transition ?? pressSpring);
  const [hovered, setHovered] = React.useState(false);
  const seconds = Number.parseFloat(delay) || 0.3;

  return (
    <motion.button
      data-slot="liquid-button"
      initial={reduce ? undefined : { scale: 1 }}
      whileTap={reduce ? undefined : { scale: tapScale }}
      whileHover={reduce || hoverScale === 1 ? undefined : { scale: hoverScale }}
      transition={spring}
      onPointerEnter={() => setHovered(true)}
      onPointerLeave={() => setHovered(false)}
      onFocus={() => setHovered(true)}
      onBlur={() => setHovered(false)}
      className={cn(
        "group relative inline-flex h-10 items-center justify-center overflow-hidden rounded-lg border border-primary/20 bg-background px-4 text-[13px] font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring/50",
        className,
      )}
      {...props}
    >
      <motion.span
        aria-hidden="true"
        initial={false}
        animate={{
          scaleY: hovered && !reduce ? 1 : 0.06,
          opacity: hovered && !reduce ? 1 : 0.55,
        }}
        transition={{
          duration: reduce ? 0 : seconds,
          ease: [0.25, 0.1, 0.35, 1],
        }}
        style={{ height: hovered ? "100%" : fillHeight }}
        className="pointer-events-none absolute inset-x-0 bottom-0 origin-bottom bg-primary"
      />
      <span
        className={cn(
          "relative z-10 transition-colors",
          hovered && !reduce ? "text-primary-foreground" : "text-foreground",
        )}
        style={{ transitionDuration: `${seconds}s` }}
      >
        {children as React.ReactNode}
      </span>
    </motion.button>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/liquid-button.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

liquid-button.tsx
import { LiquidButton } from "@/components/prequelui/liquid-button";

export default function Demo() {
  return (
    <LiquidButton delay="0.3s" fillHeight="3px">
      Fill me up
    </LiquidButton>
  );
}
import { LiquidButton } from "@/components/prequelui/liquid-button";

export function Variant() {
  return (
    <LiquidButton tempo={1.2}>
      …
    </LiquidButton>
  );
}
03

Animation

A thin bar rests at the bottom edge. Hovering lets the liquid rise from that edge until it fills the button, while the label flips to the inverse colour; leaving drains it back down the same path.

  • Fill duration: 300 ms on a soft ease-out.
  • At rest the bar keeps a 3 px height so the affordance stays visible.
  • Colour uses the same duration as the fill so text never flashes.
  • Reduced motion keeps the final hover colour without the rising layer.
fill 300 msrest height 3 pxorigin bottominverse label
04

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

LiquidButton

PropTypeDefault
delaystring"0.3s"
fillHeightstring"3px"
hoverScalenumber1
tapScalenumber0.97
transitionTransitioncomponent spring or tween

Next component

Ripple Button

A button that emits a ripple from the exact point clicked.