A button that fills with color from the bottom on hover.
Installation
Usage
<script setup lang="ts">
import LiquidButton from '@/components/animate-ui/buttons/liquid/LiquidButton.vue';
</script>
<template>
<LiquidButton>Get started</LiquidButton>
</template>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
tap-scale(0.97), and releasing springs it back (Animate UI's press spring,stiffness: 550, damping: 30). Hovering fills it without scaling it, unless you sethover-scale(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' |
fill-height? | string | '3px' |
hover-scale? | number | 1 |
tap-scale? | 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] } } |
as-child? | boolean | false |
...props? | HTMLMotionProps<'button'> | - |
CSS variables
| Prop | Type | Default |
|---|---|---|
--liquid-button-color? | color | - |
--liquid-button-background-color? | color | - |