A button that fills with color from the bottom on hover.
Installation
Usage
It fills with --primary over --muted by default. Change the two colors with CSS variables:
import { LiquidButton } from '@/components/animate-ui/buttons/liquid';
export function Start() {
return (
<LiquidButton className="[--liquid-button-background-color:var(--muted)] [--liquid-button-color:var(--primary)] hover:text-primary-foreground">
Get started
</LiquidButton>
);
}Animation
- On hover, a
fillHeightline of--liquid-button-colorslides in along the bottom, then rises to fill the button, each step takingdelay(a CSS transition). Leaving, the fill variables ease back over 0.3s, then the text color and the liquid drain in reverse. - Pressing scales the button to
tapScale(0.97), and releasing springs it back (Animate UI's press spring,stiffness: 550, damping: 30). Hovering fills it without scaling it, unless you sethoverScale(then a 0.3s ease-out). transitionreplaces the press, release and leave transitions.<AnimateUIProvider tempo>paces the Motion transitions (not the CSSdelay).- Under reduced motion, the button fills without scaling when pressed.
API Reference
LiquidButton
| Prop | Type | Default |
|---|---|---|
delay? | string | '0.3s' |
fillHeight? | string | '3px' |
hoverScale? | number | 1 |
tapScale? | number | 0.97 |
transition? | Transition | { transform: { type: 'spring', stiffness: 550, damping: 30, restSpeed: 10 }, default: { duration: 0.3, ease: [0.25, 0.1, 0.35, 1] } } |
asChild? | boolean | false |
...props? | HTMLMotionProps<'button'> | - |
CSS variables
| Prop | Type | Default |
|---|---|---|
--liquid-button-color? | color | - |
--liquid-button-background-color? | color | - |