Button Library · Hover
Liquid
Colour rises in a wave.
States
Default
Hover
Active
Focus
Code
hover-liquid.html
<button class="btn-hover-liquid" type="button"> <span>Get started</span> </button>
hover-liquid.css
.btn-hover-liquid {
--btn-bg: #7c5cff;
--btn-fg: #8b6cff;
--btn-font: inherit;
--btn-size: 15px;
--btn-weight: 600;
--btn-px: 22px;
--btn-py: 11px;
--btn-w: auto;
--btn-h: auto;
--btn-bw: 1.5px;
--btn-line: #8b6cff;
--btn-radius: 10px;
--btn-shadow: none;
--btn-speed: 180ms;
}
.btn-hover-liquid {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
box-sizing: border-box;
width: var(--btn-w);
height: var(--btn-h);
padding: var(--btn-py) var(--btn-px);
font-family: var(--btn-font);
font-size: var(--btn-size);
font-weight: var(--btn-weight);
line-height: 1.2;
color: var(--btn-fg);
background: transparent;
border: var(--btn-bw) solid var(--btn-line);
border-radius: var(--btn-radius);
box-shadow: var(--btn-shadow);
cursor: pointer;
text-decoration: none;
white-space: nowrap;
transition: all var(--btn-speed) ease;
overflow: hidden;
isolation: isolate;
}
.btn-hover-liquid:focus-visible {
outline: 2px solid var(--btn-bg);
outline-offset: 2px;
}
.btn-hover-liquid:disabled {
opacity: 0.5;
pointer-events: none;
}
.btn-hover-liquid__icon {
width: 1.15em;
height: 1.15em;
flex-shrink: 0;
}
.btn-hover-liquid::before {
content: "";
position: absolute;
left: -25%;
top: 110%;
z-index: -1;
width: 150%;
aspect-ratio: 1;
border-radius: 42%;
background: var(--btn-line);
transition: top 500ms ease, transform 900ms ease;
}
.btn-hover-liquid:hover {
color: #ffffff;
}
.btn-hover-liquid:hover::before {
top: -40%;
transform: rotate(120deg);
}
@media (prefers-reduced-motion: reduce) {
.btn-hover-liquid,
.btn-hover-liquid::before {
animation: none !important;
transition: none !important;
}
}
hover-liquid.js
// No JavaScript needed: this one is CSS only.
hover-liquid.tsx
import type React from "react";
import "./hover-liquid.css"; // the CSS tab
export function BtnHoverLiquid({ children = "Get started", ...props }: React.ComponentProps<"button">) {
return (
<button className="btn-hover-liquid" type="button" {...props}>
<span>{children}</span>
</button>
);
}
hover-liquid.html
<button class="relative inline-flex items-center justify-center gap-[0.5em] [box-sizing:border-box] [padding:11px_22px] [font-family:inherit] text-[15px] font-[600] [line-height:1.2] text-[#8b6cff] [background:transparent] [border:1.5px_solid_#8b6cff] rounded-[10px] [box-shadow:none] cursor-pointer no-underline whitespace-nowrap [transition:all_180ms_ease] overflow-hidden isolate focus-visible:[outline:2px_solid_#7c5cff] focus-visible:[outline-offset:2px] disabled:[opacity:0.5] disabled:[pointer-events:none] before:content-[''] before:absolute before:[left:-25%] before:[top:110%] before:[z-index:-1] before:w-[150%] before:[aspect-ratio:1] before:rounded-[42%] before:bg-[#8b6cff] before:[transition:top_500ms_ease,_transform_900ms_ease] hover:text-[#ffffff] hover:before:[top:-40%] hover:before:[transform:rotate(120deg)] motion-reduce:[transition:none!important] motion-reduce:before:[transition:none!important]" type="button"> <span>Get started</span> </button>