free UI sections and components / components
glass button
By Andrea Buttarelli, founder of Feega · Free · Svelte, React, Vue, Astro, HTML
A clear liquid glass pill button; a rainbow light follows the cursor and bends through the glass.
code
<script lang="ts">
const RIM = 14;
const BEND = 36;
const EASE = 0.16;
const SETTLE = 0.5;
let lenses = 0;
function lensMap(w: number, h: number): string {
const r = h / 2;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><defs><linearGradient id="x"><stop offset="0" stop-color="red"/><stop offset="1" stop-color="black"/></linearGradient><linearGradient id="y" x2="0" y2="1"><stop offset="0" stop-color="lime"/><stop offset="1" stop-color="black"/></linearGradient><filter id="s"><feGaussianBlur stdDeviation="${RIM / 2}"/></filter></defs><rect width="${w}" height="${h}" fill="black"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#x)"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#y)" style="mix-blend-mode:screen"/><rect x="${RIM}" y="${RIM}" width="${w - RIM * 2}" height="${h - RIM * 2}" rx="${r - RIM}" fill="gray" filter="url(#s)"/></svg>`;
return 'data:image/svg+xml,' + encodeURIComponent(svg);
}
function refracts(): boolean {
return CSS.supports('backdrop-filter', 'url(#a)') && 'userAgentData' in navigator;
}
function glass(root: HTMLElement): () => void {
const button = root.querySelector<HTMLElement>('.glass')!;
const glow = root.querySelector<HTMLElement>('.glow')!;
const filter = root.querySelector<SVGFilterElement>('filter')!;
const map = root.querySelector<SVGFEImageElement>('feImage')!;
const bend = root.querySelector<SVGFEDisplacementMapElement>('feDisplacementMap')!;
const speed = Number(root.dataset.speed) || 1;
const intensity = Number(root.dataset.intensity) || 1;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const id = 'fl-glass-lens-' + ++lenses;
const target = { x: 0, y: 0 };
const at = { x: 0, y: 0 };
let hovering = false;
let frame = 0;
filter.id = id;
root.style.setProperty('--spin', 6 / speed + 's');
root.style.setProperty('--glow', String(Math.min(1, 0.9 * intensity)));
bend.setAttribute('scale', String(BEND * intensity));
function resize() {
const w = Math.round(button.offsetWidth);
const h = Math.round(button.offsetHeight);
map.setAttribute('width', String(w));
map.setAttribute('height', String(h));
map.setAttribute('href', lensMap(w, h));
}
function paint() {
root.style.setProperty('--gx', at.x + 'px');
root.style.setProperty('--gy', at.y + 'px');
root.style.setProperty('--fx', at.x + glow.offsetLeft - button.offsetLeft + 'px');
root.style.setProperty('--fy', at.y + glow.offsetTop - button.offsetTop + 'px');
}
function step() {
const k = Math.min(1, EASE * speed);
at.x += (target.x - at.x) * k;
at.y += (target.y - at.y) * k;
paint();
if (Math.abs(target.x - at.x) + Math.abs(target.y - at.y) < SETTLE) {
frame = 0;
return;
}
frame = requestAnimationFrame(step);
}
function aim(x: number, y: number, move: 'jump' | 'ease') {
target.x = x;
target.y = y;
if (move === 'jump' || still.matches) {
at.x = x;
at.y = y;
paint();
return;
}
if (!frame) {
frame = requestAnimationFrame(step);
}
}
function aimAt(event: PointerEvent, move: 'jump' | 'ease') {
const box = glow.getBoundingClientRect();
const face = button.getBoundingClientRect();
root.style.setProperty('--mx', ((event.clientX - face.left) / face.width) * 100 + '%');
root.style.setProperty('--my', ((event.clientY - face.top) / face.height) * 100 + '%');
aim(event.clientX - box.left, event.clientY - box.top, move);
}
function aimCentre() {
aim(glow.offsetWidth / 2, glow.offsetHeight / 2, 'jump');
}
function showFocus() {
aimCentre();
root.setAttribute('data-lit', 'focus');
}
function onEnter(event: PointerEvent) {
if (event.pointerType === 'touch') {
return;
}
aimAt(event, root.getAttribute('data-lit') === 'pointer' ? 'ease' : 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onDown(event: PointerEvent) {
if (event.pointerType !== 'touch') {
return;
}
aimAt(event, 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onMove(event: PointerEvent) {
if (!hovering) {
return;
}
aimAt(event, 'ease');
}
function onLeave() {
hovering = false;
root.style.setProperty('--mx', '50%');
root.style.setProperty('--my', '0%');
if (button.matches(':focus-visible')) {
showFocus();
return;
}
root.removeAttribute('data-lit');
}
function onUp(event: PointerEvent) {
if (event.pointerType === 'touch') {
onLeave();
}
}
function onFocus() {
if (hovering || !button.matches(':focus-visible')) {
return;
}
showFocus();
}
function onBlur() {
if (hovering) {
return;
}
root.removeAttribute('data-lit');
}
const watch = new ResizeObserver(resize);
const events = [
[root, 'pointerenter', onEnter],
[root, 'pointerdown', onDown],
[root, 'pointermove', onMove],
[root, 'pointerleave', onLeave],
[root, 'pointerup', onUp],
[root, 'pointercancel', onLeave],
[button, 'focus', onFocus],
[button, 'blur', onBlur]
] as [HTMLElement, string, (event: any) => void][];
if (refracts()) {
root.style.setProperty('--lens', 'url(#' + id + ')');
root.setAttribute('data-lens', '');
watch.observe(button);
}
events.forEach(([el, type, fn]) => el.addEventListener(type, fn));
return () => {
cancelAnimationFrame(frame);
watch.disconnect();
events.forEach(([el, type, fn]) => el.removeEventListener(type, fn));
root.removeAttribute('data-lens');
root.removeAttribute('data-lit');
};
}
let root: HTMLElement;
$effect(() => glass(root));
</script>
<div bind:this={root} class="fl-glass-button" data-speed="1" data-intensity="1">
<span class="glow" aria-hidden="true"><span class="hue"></span></span>
<button class="glass" type="button"><span class="light" aria-hidden="true"><span class="halo"><span class="ring"></span></span><span class="ring"></span><span class="tint"></span></span><span class="label">get started</span></button>
<svg class="lens" aria-hidden="true" focusable="false">
<filter x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">
<feImage x="0" y="0" preserveAspectRatio="none" result="map" />
<feDisplacementMap in="SourceGraphic" in2="map" scale="36" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>
</div>
<style>
:global {
.fl-glass-button{font-family:var(--feega-font);font-size:var(--feega-text-body);line-height:1.5;letter-spacing:var(--feega-tracking);color:var(--feega-fg);background:var(--feega-bg);-webkit-font-smoothing:antialiased}
:where(.fl-glass-button) *,:where(.fl-glass-button) *::before,:where(.fl-glass-button) *::after{box-sizing:border-box}
:where(.fl-glass-button) :is(h1,h2,h3,h4,p,ul,ol,figure,blockquote,dl,dd){margin:0}
:where(.fl-glass-button) a{color:inherit;text-decoration:none}
:where(.fl-glass-button) :focus-visible{outline:2px solid var(--feega-focus);outline-offset:3px}
.fl-glass-button{--glow-1:deeppink;--glow-2:orange;--glow-3:gold;--glow-4:springgreen;--glow-5:deepskyblue;--glow-6:blueviolet;--shine:white;--spin:6s;--radius:var(--feega-radius-full);--blur:12px;--glow:0.9;--fade:300ms;--mx:50%;--my:0%;--gx:50%;--gy:50%;--fx:50%;--fy:50%;position:relative;display:inline-grid;place-items:center;padding:var(--feega-space-12) var(--feega-space-16);max-width:100%}
.fl-glass-button .glow{position:absolute;inset:calc(var(--feega-space-12) - 8px) calc(var(--feega-space-16) - 8px);filter:blur(var(--blur));opacity:0;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .hue{position:absolute;inset:0;background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1)) 0 0/200% 100%;opacity:0.4;-webkit-mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);animation:fl-glass-spin var(--spin) linear infinite}
@keyframes fl-glass-spin{to{background-position:200% 0}}
.fl-glass-button[data-lit] .glow{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .glow{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .glass{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:56px;max-width:100%;padding:0 var(--feega-space-8);border:0;border-radius:var(--radius);background:linear-gradient(180deg,color-mix(in srgb,var(--feega-raised) 30%,transparent),color-mix(in srgb,var(--feega-raised) 8%,transparent));color:var(--feega-fg);font:inherit;font-size:1.0625rem;font-weight:500;letter-spacing:var(--feega-tracking);white-space:nowrap;cursor:pointer;-webkit-backdrop-filter:blur(8px) saturate(1.6);backdrop-filter:blur(8px) saturate(1.6);box-shadow:inset 0 1px 0 color-mix(in srgb,var(--shine) 80%,transparent),inset 0 -1px 0 color-mix(in srgb,var(--shine) 25%,transparent),inset 0 -12px 20px -12px color-mix(in srgb,var(--feega-fg) 22%,transparent),inset 1px 0 0 color-mix(in srgb,var(--glow-5) 22%,transparent),inset -1px 0 0 color-mix(in srgb,var(--glow-1) 22%,transparent),0 0 0 1px color-mix(in srgb,var(--feega-fg) 8%,transparent),0 8px 24px -12px color-mix(in srgb,var(--feega-fg) 30%,transparent);transition:transform var(--feega-dur-fast) var(--feega-ease)}
.fl-glass-button[data-lens] .glass{-webkit-backdrop-filter:var(--lens) blur(1.5px) saturate(1.6);backdrop-filter:var(--lens) blur(1.5px) saturate(1.6)}
.fl-glass-button .glass::before{content:"";position:absolute;inset:0;padding:1.5px;border-radius:inherit;background:radial-gradient(90% 130% at var(--mx) var(--my),var(--shine),transparent 70%);-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);pointer-events:none}
.fl-glass-button .glass::after{content:"";position:absolute;inset:0;border-radius:inherit;background:radial-gradient(60% 90% at var(--mx) var(--my),color-mix(in srgb,var(--shine) 40%,transparent),transparent 70%);opacity:0.3;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .light{position:absolute;inset:-8px;opacity:0;pointer-events:none;-webkit-mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .halo{position:absolute;inset:0;filter:blur(5px);opacity:0.8}
.fl-glass-button .ring{position:absolute;inset:8px;padding:1.5px;border-radius:var(--radius);background:conic-gradient(from 90deg at var(--fx) var(--fy),var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0)}
.fl-glass-button .halo .ring{padding:5px}
.fl-glass-button .tint{position:absolute;inset:8px;border-radius:var(--radius);background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));opacity:0.12;filter:blur(6px)}
.fl-glass-button[data-lit] .light{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .light{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .label{position:relative;z-index:1;text-shadow:0 1px 1px color-mix(in srgb,var(--feega-bg) 45%,transparent)}
.fl-glass-button .lens{position:absolute;width:0;height:0;overflow:hidden}
.fl-glass-button[data-lit] .glass::after{opacity:0.6}
.fl-glass-button .glass:active{transform:scale(0.97,0.93)}
@media (prefers-reduced-motion:reduce){.fl-glass-button .hue{animation:none}.fl-glass-button .glow,.fl-glass-button .light{transition:none}}
@media (prefers-reduced-motion:reduce){:where([class^="fl-"]) *,:where([class^="fl-"]) *::before,:where([class^="fl-"]) *::after{animation:none!important;transition:none!important}}
}
</style>
import { useEffect, useRef } from 'react';
import './GlassButton.css';
const RIM = 14;
const BEND = 36;
const EASE = 0.16;
const SETTLE = 0.5;
let lenses = 0;
function lensMap(w: number, h: number): string {
const r = h / 2;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><defs><linearGradient id="x"><stop offset="0" stop-color="red"/><stop offset="1" stop-color="black"/></linearGradient><linearGradient id="y" x2="0" y2="1"><stop offset="0" stop-color="lime"/><stop offset="1" stop-color="black"/></linearGradient><filter id="s"><feGaussianBlur stdDeviation="${RIM / 2}"/></filter></defs><rect width="${w}" height="${h}" fill="black"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#x)"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#y)" style="mix-blend-mode:screen"/><rect x="${RIM}" y="${RIM}" width="${w - RIM * 2}" height="${h - RIM * 2}" rx="${r - RIM}" fill="gray" filter="url(#s)"/></svg>`;
return 'data:image/svg+xml,' + encodeURIComponent(svg);
}
function refracts(): boolean {
return CSS.supports('backdrop-filter', 'url(#a)') && 'userAgentData' in navigator;
}
function glass(root: HTMLElement): () => void {
const button = root.querySelector<HTMLElement>('.glass')!;
const glow = root.querySelector<HTMLElement>('.glow')!;
const filter = root.querySelector<SVGFilterElement>('filter')!;
const map = root.querySelector<SVGFEImageElement>('feImage')!;
const bend = root.querySelector<SVGFEDisplacementMapElement>('feDisplacementMap')!;
const speed = Number(root.dataset.speed) || 1;
const intensity = Number(root.dataset.intensity) || 1;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const id = 'fl-glass-lens-' + ++lenses;
const target = { x: 0, y: 0 };
const at = { x: 0, y: 0 };
let hovering = false;
let frame = 0;
filter.id = id;
root.style.setProperty('--spin', 6 / speed + 's');
root.style.setProperty('--glow', String(Math.min(1, 0.9 * intensity)));
bend.setAttribute('scale', String(BEND * intensity));
function resize() {
const w = Math.round(button.offsetWidth);
const h = Math.round(button.offsetHeight);
map.setAttribute('width', String(w));
map.setAttribute('height', String(h));
map.setAttribute('href', lensMap(w, h));
}
function paint() {
root.style.setProperty('--gx', at.x + 'px');
root.style.setProperty('--gy', at.y + 'px');
root.style.setProperty('--fx', at.x + glow.offsetLeft - button.offsetLeft + 'px');
root.style.setProperty('--fy', at.y + glow.offsetTop - button.offsetTop + 'px');
}
function step() {
const k = Math.min(1, EASE * speed);
at.x += (target.x - at.x) * k;
at.y += (target.y - at.y) * k;
paint();
if (Math.abs(target.x - at.x) + Math.abs(target.y - at.y) < SETTLE) {
frame = 0;
return;
}
frame = requestAnimationFrame(step);
}
function aim(x: number, y: number, move: 'jump' | 'ease') {
target.x = x;
target.y = y;
if (move === 'jump' || still.matches) {
at.x = x;
at.y = y;
paint();
return;
}
if (!frame) {
frame = requestAnimationFrame(step);
}
}
function aimAt(event: PointerEvent, move: 'jump' | 'ease') {
const box = glow.getBoundingClientRect();
const face = button.getBoundingClientRect();
root.style.setProperty('--mx', ((event.clientX - face.left) / face.width) * 100 + '%');
root.style.setProperty('--my', ((event.clientY - face.top) / face.height) * 100 + '%');
aim(event.clientX - box.left, event.clientY - box.top, move);
}
function aimCentre() {
aim(glow.offsetWidth / 2, glow.offsetHeight / 2, 'jump');
}
function showFocus() {
aimCentre();
root.setAttribute('data-lit', 'focus');
}
function onEnter(event: PointerEvent) {
if (event.pointerType === 'touch') {
return;
}
aimAt(event, root.getAttribute('data-lit') === 'pointer' ? 'ease' : 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onDown(event: PointerEvent) {
if (event.pointerType !== 'touch') {
return;
}
aimAt(event, 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onMove(event: PointerEvent) {
if (!hovering) {
return;
}
aimAt(event, 'ease');
}
function onLeave() {
hovering = false;
root.style.setProperty('--mx', '50%');
root.style.setProperty('--my', '0%');
if (button.matches(':focus-visible')) {
showFocus();
return;
}
root.removeAttribute('data-lit');
}
function onUp(event: PointerEvent) {
if (event.pointerType === 'touch') {
onLeave();
}
}
function onFocus() {
if (hovering || !button.matches(':focus-visible')) {
return;
}
showFocus();
}
function onBlur() {
if (hovering) {
return;
}
root.removeAttribute('data-lit');
}
const watch = new ResizeObserver(resize);
const events = [
[root, 'pointerenter', onEnter],
[root, 'pointerdown', onDown],
[root, 'pointermove', onMove],
[root, 'pointerleave', onLeave],
[root, 'pointerup', onUp],
[root, 'pointercancel', onLeave],
[button, 'focus', onFocus],
[button, 'blur', onBlur]
] as [HTMLElement, string, (event: any) => void][];
if (refracts()) {
root.style.setProperty('--lens', 'url(#' + id + ')');
root.setAttribute('data-lens', '');
watch.observe(button);
}
events.forEach(([el, type, fn]) => el.addEventListener(type, fn));
return () => {
cancelAnimationFrame(frame);
watch.disconnect();
events.forEach(([el, type, fn]) => el.removeEventListener(type, fn));
root.removeAttribute('data-lens');
root.removeAttribute('data-lit');
};
}
export function GlassButton() {
const root = useRef<HTMLDivElement>(null);
useEffect(() => (root.current ? glass(root.current) : undefined), []);
return (
<div ref={root} className="fl-glass-button" data-speed="1" data-intensity="1">
<span className="glow" aria-hidden="true"><span className="hue"></span></span>
<button className="glass" type="button"><span className="light" aria-hidden="true"><span className="halo"><span className="ring"></span></span><span className="ring"></span><span className="tint"></span></span><span className="label">get started</span></button>
<svg className="lens" aria-hidden="true" focusable="false">
<filter x="0" y="0" width="100%" height="100%" colorInterpolationFilters="sRGB">
<feImage x="0" y="0" preserveAspectRatio="none" result="map" />
<feDisplacementMap in="SourceGraphic" in2="map" scale="36" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>
</div>
);
}
.fl-glass-button{font-family:var(--feega-font);font-size:var(--feega-text-body);line-height:1.5;letter-spacing:var(--feega-tracking);color:var(--feega-fg);background:var(--feega-bg);-webkit-font-smoothing:antialiased}
:where(.fl-glass-button) *,:where(.fl-glass-button) *::before,:where(.fl-glass-button) *::after{box-sizing:border-box}
:where(.fl-glass-button) :is(h1,h2,h3,h4,p,ul,ol,figure,blockquote,dl,dd){margin:0}
:where(.fl-glass-button) a{color:inherit;text-decoration:none}
:where(.fl-glass-button) :focus-visible{outline:2px solid var(--feega-focus);outline-offset:3px}
.fl-glass-button{--glow-1:deeppink;--glow-2:orange;--glow-3:gold;--glow-4:springgreen;--glow-5:deepskyblue;--glow-6:blueviolet;--shine:white;--spin:6s;--radius:var(--feega-radius-full);--blur:12px;--glow:0.9;--fade:300ms;--mx:50%;--my:0%;--gx:50%;--gy:50%;--fx:50%;--fy:50%;position:relative;display:inline-grid;place-items:center;padding:var(--feega-space-12) var(--feega-space-16);max-width:100%}
.fl-glass-button .glow{position:absolute;inset:calc(var(--feega-space-12) - 8px) calc(var(--feega-space-16) - 8px);filter:blur(var(--blur));opacity:0;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .hue{position:absolute;inset:0;background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1)) 0 0/200% 100%;opacity:0.4;-webkit-mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);animation:fl-glass-spin var(--spin) linear infinite}
@keyframes fl-glass-spin{to{background-position:200% 0}}
.fl-glass-button[data-lit] .glow{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .glow{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .glass{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:56px;max-width:100%;padding:0 var(--feega-space-8);border:0;border-radius:var(--radius);background:linear-gradient(180deg,color-mix(in srgb,var(--feega-raised) 30%,transparent),color-mix(in srgb,var(--feega-raised) 8%,transparent));color:var(--feega-fg);font:inherit;font-size:1.0625rem;font-weight:500;letter-spacing:var(--feega-tracking);white-space:nowrap;cursor:pointer;-webkit-backdrop-filter:blur(8px) saturate(1.6);backdrop-filter:blur(8px) saturate(1.6);box-shadow:inset 0 1px 0 color-mix(in srgb,var(--shine) 80%,transparent),inset 0 -1px 0 color-mix(in srgb,var(--shine) 25%,transparent),inset 0 -12px 20px -12px color-mix(in srgb,var(--feega-fg) 22%,transparent),inset 1px 0 0 color-mix(in srgb,var(--glow-5) 22%,transparent),inset -1px 0 0 color-mix(in srgb,var(--glow-1) 22%,transparent),0 0 0 1px color-mix(in srgb,var(--feega-fg) 8%,transparent),0 8px 24px -12px color-mix(in srgb,var(--feega-fg) 30%,transparent);transition:transform var(--feega-dur-fast) var(--feega-ease)}
.fl-glass-button[data-lens] .glass{-webkit-backdrop-filter:var(--lens) blur(1.5px) saturate(1.6);backdrop-filter:var(--lens) blur(1.5px) saturate(1.6)}
.fl-glass-button .glass::before{content:"";position:absolute;inset:0;padding:1.5px;border-radius:inherit;background:radial-gradient(90% 130% at var(--mx) var(--my),var(--shine),transparent 70%);-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);pointer-events:none}
.fl-glass-button .glass::after{content:"";position:absolute;inset:0;border-radius:inherit;background:radial-gradient(60% 90% at var(--mx) var(--my),color-mix(in srgb,var(--shine) 40%,transparent),transparent 70%);opacity:0.3;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .light{position:absolute;inset:-8px;opacity:0;pointer-events:none;-webkit-mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .halo{position:absolute;inset:0;filter:blur(5px);opacity:0.8}
.fl-glass-button .ring{position:absolute;inset:8px;padding:1.5px;border-radius:var(--radius);background:conic-gradient(from 90deg at var(--fx) var(--fy),var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0)}
.fl-glass-button .halo .ring{padding:5px}
.fl-glass-button .tint{position:absolute;inset:8px;border-radius:var(--radius);background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));opacity:0.12;filter:blur(6px)}
.fl-glass-button[data-lit] .light{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .light{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .label{position:relative;z-index:1;text-shadow:0 1px 1px color-mix(in srgb,var(--feega-bg) 45%,transparent)}
.fl-glass-button .lens{position:absolute;width:0;height:0;overflow:hidden}
.fl-glass-button[data-lit] .glass::after{opacity:0.6}
.fl-glass-button .glass:active{transform:scale(0.97,0.93)}
@media (prefers-reduced-motion:reduce){.fl-glass-button .hue{animation:none}.fl-glass-button .glow,.fl-glass-button .light{transition:none}}
@media (prefers-reduced-motion:reduce){:where([class^="fl-"]) *,:where([class^="fl-"]) *::before,:where([class^="fl-"]) *::after{animation:none!important;transition:none!important}}
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
const RIM = 14;
const BEND = 36;
const EASE = 0.16;
const SETTLE = 0.5;
let lenses = 0;
function lensMap(w: number, h: number): string {
const r = h / 2;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><defs><linearGradient id="x"><stop offset="0" stop-color="red"/><stop offset="1" stop-color="black"/></linearGradient><linearGradient id="y" x2="0" y2="1"><stop offset="0" stop-color="lime"/><stop offset="1" stop-color="black"/></linearGradient><filter id="s"><feGaussianBlur stdDeviation="${RIM / 2}"/></filter></defs><rect width="${w}" height="${h}" fill="black"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#x)"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#y)" style="mix-blend-mode:screen"/><rect x="${RIM}" y="${RIM}" width="${w - RIM * 2}" height="${h - RIM * 2}" rx="${r - RIM}" fill="gray" filter="url(#s)"/></svg>`;
return 'data:image/svg+xml,' + encodeURIComponent(svg);
}
function refracts(): boolean {
return CSS.supports('backdrop-filter', 'url(#a)') && 'userAgentData' in navigator;
}
function glass(root: HTMLElement): () => void {
const button = root.querySelector<HTMLElement>('.glass')!;
const glow = root.querySelector<HTMLElement>('.glow')!;
const filter = root.querySelector<SVGFilterElement>('filter')!;
const map = root.querySelector<SVGFEImageElement>('feImage')!;
const bend = root.querySelector<SVGFEDisplacementMapElement>('feDisplacementMap')!;
const speed = Number(root.dataset.speed) || 1;
const intensity = Number(root.dataset.intensity) || 1;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const id = 'fl-glass-lens-' + ++lenses;
const target = { x: 0, y: 0 };
const at = { x: 0, y: 0 };
let hovering = false;
let frame = 0;
filter.id = id;
root.style.setProperty('--spin', 6 / speed + 's');
root.style.setProperty('--glow', String(Math.min(1, 0.9 * intensity)));
bend.setAttribute('scale', String(BEND * intensity));
function resize() {
const w = Math.round(button.offsetWidth);
const h = Math.round(button.offsetHeight);
map.setAttribute('width', String(w));
map.setAttribute('height', String(h));
map.setAttribute('href', lensMap(w, h));
}
function paint() {
root.style.setProperty('--gx', at.x + 'px');
root.style.setProperty('--gy', at.y + 'px');
root.style.setProperty('--fx', at.x + glow.offsetLeft - button.offsetLeft + 'px');
root.style.setProperty('--fy', at.y + glow.offsetTop - button.offsetTop + 'px');
}
function step() {
const k = Math.min(1, EASE * speed);
at.x += (target.x - at.x) * k;
at.y += (target.y - at.y) * k;
paint();
if (Math.abs(target.x - at.x) + Math.abs(target.y - at.y) < SETTLE) {
frame = 0;
return;
}
frame = requestAnimationFrame(step);
}
function aim(x: number, y: number, move: 'jump' | 'ease') {
target.x = x;
target.y = y;
if (move === 'jump' || still.matches) {
at.x = x;
at.y = y;
paint();
return;
}
if (!frame) {
frame = requestAnimationFrame(step);
}
}
function aimAt(event: PointerEvent, move: 'jump' | 'ease') {
const box = glow.getBoundingClientRect();
const face = button.getBoundingClientRect();
root.style.setProperty('--mx', ((event.clientX - face.left) / face.width) * 100 + '%');
root.style.setProperty('--my', ((event.clientY - face.top) / face.height) * 100 + '%');
aim(event.clientX - box.left, event.clientY - box.top, move);
}
function aimCentre() {
aim(glow.offsetWidth / 2, glow.offsetHeight / 2, 'jump');
}
function showFocus() {
aimCentre();
root.setAttribute('data-lit', 'focus');
}
function onEnter(event: PointerEvent) {
if (event.pointerType === 'touch') {
return;
}
aimAt(event, root.getAttribute('data-lit') === 'pointer' ? 'ease' : 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onDown(event: PointerEvent) {
if (event.pointerType !== 'touch') {
return;
}
aimAt(event, 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onMove(event: PointerEvent) {
if (!hovering) {
return;
}
aimAt(event, 'ease');
}
function onLeave() {
hovering = false;
root.style.setProperty('--mx', '50%');
root.style.setProperty('--my', '0%');
if (button.matches(':focus-visible')) {
showFocus();
return;
}
root.removeAttribute('data-lit');
}
function onUp(event: PointerEvent) {
if (event.pointerType === 'touch') {
onLeave();
}
}
function onFocus() {
if (hovering || !button.matches(':focus-visible')) {
return;
}
showFocus();
}
function onBlur() {
if (hovering) {
return;
}
root.removeAttribute('data-lit');
}
const watch = new ResizeObserver(resize);
const events = [
[root, 'pointerenter', onEnter],
[root, 'pointerdown', onDown],
[root, 'pointermove', onMove],
[root, 'pointerleave', onLeave],
[root, 'pointerup', onUp],
[root, 'pointercancel', onLeave],
[button, 'focus', onFocus],
[button, 'blur', onBlur]
] as [HTMLElement, string, (event: any) => void][];
if (refracts()) {
root.style.setProperty('--lens', 'url(#' + id + ')');
root.setAttribute('data-lens', '');
watch.observe(button);
}
events.forEach(([el, type, fn]) => el.addEventListener(type, fn));
return () => {
cancelAnimationFrame(frame);
watch.disconnect();
events.forEach(([el, type, fn]) => el.removeEventListener(type, fn));
root.removeAttribute('data-lens');
root.removeAttribute('data-lit');
};
}
const root = ref<HTMLElement | null>(null);
let stop = () => {};
onMounted(() => {
stop = glass(root.value as HTMLElement);
});
onBeforeUnmount(() => stop());
</script>
<template>
<div ref="root" class="fl-glass-button" data-speed="1" data-intensity="1">
<span class="glow" aria-hidden="true"><span class="hue"></span></span>
<button class="glass" type="button"><span class="light" aria-hidden="true"><span class="halo"><span class="ring"></span></span><span class="ring"></span><span class="tint"></span></span><span class="label">get started</span></button>
<svg class="lens" aria-hidden="true" focusable="false">
<filter x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">
<feImage x="0" y="0" preserveAspectRatio="none" result="map" />
<feDisplacementMap in="SourceGraphic" in2="map" scale="36" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>
</div>
</template>
<style>
.fl-glass-button{font-family:var(--feega-font);font-size:var(--feega-text-body);line-height:1.5;letter-spacing:var(--feega-tracking);color:var(--feega-fg);background:var(--feega-bg);-webkit-font-smoothing:antialiased}
:where(.fl-glass-button) *,:where(.fl-glass-button) *::before,:where(.fl-glass-button) *::after{box-sizing:border-box}
:where(.fl-glass-button) :is(h1,h2,h3,h4,p,ul,ol,figure,blockquote,dl,dd){margin:0}
:where(.fl-glass-button) a{color:inherit;text-decoration:none}
:where(.fl-glass-button) :focus-visible{outline:2px solid var(--feega-focus);outline-offset:3px}
.fl-glass-button{--glow-1:deeppink;--glow-2:orange;--glow-3:gold;--glow-4:springgreen;--glow-5:deepskyblue;--glow-6:blueviolet;--shine:white;--spin:6s;--radius:var(--feega-radius-full);--blur:12px;--glow:0.9;--fade:300ms;--mx:50%;--my:0%;--gx:50%;--gy:50%;--fx:50%;--fy:50%;position:relative;display:inline-grid;place-items:center;padding:var(--feega-space-12) var(--feega-space-16);max-width:100%}
.fl-glass-button .glow{position:absolute;inset:calc(var(--feega-space-12) - 8px) calc(var(--feega-space-16) - 8px);filter:blur(var(--blur));opacity:0;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .hue{position:absolute;inset:0;background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1)) 0 0/200% 100%;opacity:0.4;-webkit-mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);animation:fl-glass-spin var(--spin) linear infinite}
@keyframes fl-glass-spin{to{background-position:200% 0}}
.fl-glass-button[data-lit] .glow{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .glow{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .glass{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:56px;max-width:100%;padding:0 var(--feega-space-8);border:0;border-radius:var(--radius);background:linear-gradient(180deg,color-mix(in srgb,var(--feega-raised) 30%,transparent),color-mix(in srgb,var(--feega-raised) 8%,transparent));color:var(--feega-fg);font:inherit;font-size:1.0625rem;font-weight:500;letter-spacing:var(--feega-tracking);white-space:nowrap;cursor:pointer;-webkit-backdrop-filter:blur(8px) saturate(1.6);backdrop-filter:blur(8px) saturate(1.6);box-shadow:inset 0 1px 0 color-mix(in srgb,var(--shine) 80%,transparent),inset 0 -1px 0 color-mix(in srgb,var(--shine) 25%,transparent),inset 0 -12px 20px -12px color-mix(in srgb,var(--feega-fg) 22%,transparent),inset 1px 0 0 color-mix(in srgb,var(--glow-5) 22%,transparent),inset -1px 0 0 color-mix(in srgb,var(--glow-1) 22%,transparent),0 0 0 1px color-mix(in srgb,var(--feega-fg) 8%,transparent),0 8px 24px -12px color-mix(in srgb,var(--feega-fg) 30%,transparent);transition:transform var(--feega-dur-fast) var(--feega-ease)}
.fl-glass-button[data-lens] .glass{-webkit-backdrop-filter:var(--lens) blur(1.5px) saturate(1.6);backdrop-filter:var(--lens) blur(1.5px) saturate(1.6)}
.fl-glass-button .glass::before{content:"";position:absolute;inset:0;padding:1.5px;border-radius:inherit;background:radial-gradient(90% 130% at var(--mx) var(--my),var(--shine),transparent 70%);-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);pointer-events:none}
.fl-glass-button .glass::after{content:"";position:absolute;inset:0;border-radius:inherit;background:radial-gradient(60% 90% at var(--mx) var(--my),color-mix(in srgb,var(--shine) 40%,transparent),transparent 70%);opacity:0.3;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .light{position:absolute;inset:-8px;opacity:0;pointer-events:none;-webkit-mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .halo{position:absolute;inset:0;filter:blur(5px);opacity:0.8}
.fl-glass-button .ring{position:absolute;inset:8px;padding:1.5px;border-radius:var(--radius);background:conic-gradient(from 90deg at var(--fx) var(--fy),var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0)}
.fl-glass-button .halo .ring{padding:5px}
.fl-glass-button .tint{position:absolute;inset:8px;border-radius:var(--radius);background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));opacity:0.12;filter:blur(6px)}
.fl-glass-button[data-lit] .light{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .light{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .label{position:relative;z-index:1;text-shadow:0 1px 1px color-mix(in srgb,var(--feega-bg) 45%,transparent)}
.fl-glass-button .lens{position:absolute;width:0;height:0;overflow:hidden}
.fl-glass-button[data-lit] .glass::after{opacity:0.6}
.fl-glass-button .glass:active{transform:scale(0.97,0.93)}
@media (prefers-reduced-motion:reduce){.fl-glass-button .hue{animation:none}.fl-glass-button .glow,.fl-glass-button .light{transition:none}}
@media (prefers-reduced-motion:reduce){:where([class^="fl-"]) *,:where([class^="fl-"]) *::before,:where([class^="fl-"]) *::after{animation:none!important;transition:none!important}}
</style>
---
---
<div class="fl-glass-button" data-speed="1" data-intensity="1">
<span class="glow" aria-hidden="true"><span class="hue"></span></span>
<button class="glass" type="button"><span class="light" aria-hidden="true"><span class="halo"><span class="ring"></span></span><span class="ring"></span><span class="tint"></span></span><span class="label">get started</span></button>
<svg class="lens" aria-hidden="true" focusable="false">
<filter x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">
<feImage x="0" y="0" preserveAspectRatio="none" result="map" />
<feDisplacementMap in="SourceGraphic" in2="map" scale="36" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>
</div>
<script>
const RIM = 14;
const BEND = 36;
const EASE = 0.16;
const SETTLE = 0.5;
let lenses = 0;
function lensMap(w: number, h: number): string {
const r = h / 2;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><defs><linearGradient id="x"><stop offset="0" stop-color="red"/><stop offset="1" stop-color="black"/></linearGradient><linearGradient id="y" x2="0" y2="1"><stop offset="0" stop-color="lime"/><stop offset="1" stop-color="black"/></linearGradient><filter id="s"><feGaussianBlur stdDeviation="${RIM / 2}"/></filter></defs><rect width="${w}" height="${h}" fill="black"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#x)"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#y)" style="mix-blend-mode:screen"/><rect x="${RIM}" y="${RIM}" width="${w - RIM * 2}" height="${h - RIM * 2}" rx="${r - RIM}" fill="gray" filter="url(#s)"/></svg>`;
return 'data:image/svg+xml,' + encodeURIComponent(svg);
}
function refracts(): boolean {
return CSS.supports('backdrop-filter', 'url(#a)') && 'userAgentData' in navigator;
}
function glass(root: HTMLElement): () => void {
const button = root.querySelector<HTMLElement>('.glass')!;
const glow = root.querySelector<HTMLElement>('.glow')!;
const filter = root.querySelector<SVGFilterElement>('filter')!;
const map = root.querySelector<SVGFEImageElement>('feImage')!;
const bend = root.querySelector<SVGFEDisplacementMapElement>('feDisplacementMap')!;
const speed = Number(root.dataset.speed) || 1;
const intensity = Number(root.dataset.intensity) || 1;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const id = 'fl-glass-lens-' + ++lenses;
const target = { x: 0, y: 0 };
const at = { x: 0, y: 0 };
let hovering = false;
let frame = 0;
filter.id = id;
root.style.setProperty('--spin', 6 / speed + 's');
root.style.setProperty('--glow', String(Math.min(1, 0.9 * intensity)));
bend.setAttribute('scale', String(BEND * intensity));
function resize() {
const w = Math.round(button.offsetWidth);
const h = Math.round(button.offsetHeight);
map.setAttribute('width', String(w));
map.setAttribute('height', String(h));
map.setAttribute('href', lensMap(w, h));
}
function paint() {
root.style.setProperty('--gx', at.x + 'px');
root.style.setProperty('--gy', at.y + 'px');
root.style.setProperty('--fx', at.x + glow.offsetLeft - button.offsetLeft + 'px');
root.style.setProperty('--fy', at.y + glow.offsetTop - button.offsetTop + 'px');
}
function step() {
const k = Math.min(1, EASE * speed);
at.x += (target.x - at.x) * k;
at.y += (target.y - at.y) * k;
paint();
if (Math.abs(target.x - at.x) + Math.abs(target.y - at.y) < SETTLE) {
frame = 0;
return;
}
frame = requestAnimationFrame(step);
}
function aim(x: number, y: number, move: 'jump' | 'ease') {
target.x = x;
target.y = y;
if (move === 'jump' || still.matches) {
at.x = x;
at.y = y;
paint();
return;
}
if (!frame) {
frame = requestAnimationFrame(step);
}
}
function aimAt(event: PointerEvent, move: 'jump' | 'ease') {
const box = glow.getBoundingClientRect();
const face = button.getBoundingClientRect();
root.style.setProperty('--mx', ((event.clientX - face.left) / face.width) * 100 + '%');
root.style.setProperty('--my', ((event.clientY - face.top) / face.height) * 100 + '%');
aim(event.clientX - box.left, event.clientY - box.top, move);
}
function aimCentre() {
aim(glow.offsetWidth / 2, glow.offsetHeight / 2, 'jump');
}
function showFocus() {
aimCentre();
root.setAttribute('data-lit', 'focus');
}
function onEnter(event: PointerEvent) {
if (event.pointerType === 'touch') {
return;
}
aimAt(event, root.getAttribute('data-lit') === 'pointer' ? 'ease' : 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onDown(event: PointerEvent) {
if (event.pointerType !== 'touch') {
return;
}
aimAt(event, 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onMove(event: PointerEvent) {
if (!hovering) {
return;
}
aimAt(event, 'ease');
}
function onLeave() {
hovering = false;
root.style.setProperty('--mx', '50%');
root.style.setProperty('--my', '0%');
if (button.matches(':focus-visible')) {
showFocus();
return;
}
root.removeAttribute('data-lit');
}
function onUp(event: PointerEvent) {
if (event.pointerType === 'touch') {
onLeave();
}
}
function onFocus() {
if (hovering || !button.matches(':focus-visible')) {
return;
}
showFocus();
}
function onBlur() {
if (hovering) {
return;
}
root.removeAttribute('data-lit');
}
const watch = new ResizeObserver(resize);
const events = [
[root, 'pointerenter', onEnter],
[root, 'pointerdown', onDown],
[root, 'pointermove', onMove],
[root, 'pointerleave', onLeave],
[root, 'pointerup', onUp],
[root, 'pointercancel', onLeave],
[button, 'focus', onFocus],
[button, 'blur', onBlur]
] as [HTMLElement, string, (event: any) => void][];
if (refracts()) {
root.style.setProperty('--lens', 'url(#' + id + ')');
root.setAttribute('data-lens', '');
watch.observe(button);
}
events.forEach(([el, type, fn]) => el.addEventListener(type, fn));
return () => {
cancelAnimationFrame(frame);
watch.disconnect();
events.forEach(([el, type, fn]) => el.removeEventListener(type, fn));
root.removeAttribute('data-lens');
root.removeAttribute('data-lit');
};
}
document.querySelectorAll<HTMLElement>('.fl-glass-button:not([data-ready])').forEach((root) => {
root.setAttribute('data-ready', '');
glass(root);
});
</script>
<style is:global>
.fl-glass-button{font-family:var(--feega-font);font-size:var(--feega-text-body);line-height:1.5;letter-spacing:var(--feega-tracking);color:var(--feega-fg);background:var(--feega-bg);-webkit-font-smoothing:antialiased}
:where(.fl-glass-button) *,:where(.fl-glass-button) *::before,:where(.fl-glass-button) *::after{box-sizing:border-box}
:where(.fl-glass-button) :is(h1,h2,h3,h4,p,ul,ol,figure,blockquote,dl,dd){margin:0}
:where(.fl-glass-button) a{color:inherit;text-decoration:none}
:where(.fl-glass-button) :focus-visible{outline:2px solid var(--feega-focus);outline-offset:3px}
.fl-glass-button{--glow-1:deeppink;--glow-2:orange;--glow-3:gold;--glow-4:springgreen;--glow-5:deepskyblue;--glow-6:blueviolet;--shine:white;--spin:6s;--radius:var(--feega-radius-full);--blur:12px;--glow:0.9;--fade:300ms;--mx:50%;--my:0%;--gx:50%;--gy:50%;--fx:50%;--fy:50%;position:relative;display:inline-grid;place-items:center;padding:var(--feega-space-12) var(--feega-space-16);max-width:100%}
.fl-glass-button .glow{position:absolute;inset:calc(var(--feega-space-12) - 8px) calc(var(--feega-space-16) - 8px);filter:blur(var(--blur));opacity:0;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .hue{position:absolute;inset:0;background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1)) 0 0/200% 100%;opacity:0.4;-webkit-mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);animation:fl-glass-spin var(--spin) linear infinite}
@keyframes fl-glass-spin{to{background-position:200% 0}}
.fl-glass-button[data-lit] .glow{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .glow{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .glass{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:56px;max-width:100%;padding:0 var(--feega-space-8);border:0;border-radius:var(--radius);background:linear-gradient(180deg,color-mix(in srgb,var(--feega-raised) 30%,transparent),color-mix(in srgb,var(--feega-raised) 8%,transparent));color:var(--feega-fg);font:inherit;font-size:1.0625rem;font-weight:500;letter-spacing:var(--feega-tracking);white-space:nowrap;cursor:pointer;-webkit-backdrop-filter:blur(8px) saturate(1.6);backdrop-filter:blur(8px) saturate(1.6);box-shadow:inset 0 1px 0 color-mix(in srgb,var(--shine) 80%,transparent),inset 0 -1px 0 color-mix(in srgb,var(--shine) 25%,transparent),inset 0 -12px 20px -12px color-mix(in srgb,var(--feega-fg) 22%,transparent),inset 1px 0 0 color-mix(in srgb,var(--glow-5) 22%,transparent),inset -1px 0 0 color-mix(in srgb,var(--glow-1) 22%,transparent),0 0 0 1px color-mix(in srgb,var(--feega-fg) 8%,transparent),0 8px 24px -12px color-mix(in srgb,var(--feega-fg) 30%,transparent);transition:transform var(--feega-dur-fast) var(--feega-ease)}
.fl-glass-button[data-lens] .glass{-webkit-backdrop-filter:var(--lens) blur(1.5px) saturate(1.6);backdrop-filter:var(--lens) blur(1.5px) saturate(1.6)}
.fl-glass-button .glass::before{content:"";position:absolute;inset:0;padding:1.5px;border-radius:inherit;background:radial-gradient(90% 130% at var(--mx) var(--my),var(--shine),transparent 70%);-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);pointer-events:none}
.fl-glass-button .glass::after{content:"";position:absolute;inset:0;border-radius:inherit;background:radial-gradient(60% 90% at var(--mx) var(--my),color-mix(in srgb,var(--shine) 40%,transparent),transparent 70%);opacity:0.3;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .light{position:absolute;inset:-8px;opacity:0;pointer-events:none;-webkit-mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .halo{position:absolute;inset:0;filter:blur(5px);opacity:0.8}
.fl-glass-button .ring{position:absolute;inset:8px;padding:1.5px;border-radius:var(--radius);background:conic-gradient(from 90deg at var(--fx) var(--fy),var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0)}
.fl-glass-button .halo .ring{padding:5px}
.fl-glass-button .tint{position:absolute;inset:8px;border-radius:var(--radius);background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));opacity:0.12;filter:blur(6px)}
.fl-glass-button[data-lit] .light{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .light{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .label{position:relative;z-index:1;text-shadow:0 1px 1px color-mix(in srgb,var(--feega-bg) 45%,transparent)}
.fl-glass-button .lens{position:absolute;width:0;height:0;overflow:hidden}
.fl-glass-button[data-lit] .glass::after{opacity:0.6}
.fl-glass-button .glass:active{transform:scale(0.97,0.93)}
@media (prefers-reduced-motion:reduce){.fl-glass-button .hue{animation:none}.fl-glass-button .glow,.fl-glass-button .light{transition:none}}
@media (prefers-reduced-motion:reduce){:where([class^="fl-"]) *,:where([class^="fl-"]) *::before,:where([class^="fl-"]) *::after{animation:none!important;transition:none!important}}
</style>
<div class="fl-glass-button" data-speed="1" data-intensity="1">
<span class="glow" aria-hidden="true"><span class="hue"></span></span>
<button class="glass" type="button"><span class="light" aria-hidden="true"><span class="halo"><span class="ring"></span></span><span class="ring"></span><span class="tint"></span></span><span class="label">get started</span></button>
<svg class="lens" aria-hidden="true" focusable="false">
<filter x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">
<feImage x="0" y="0" preserveAspectRatio="none" result="map" />
<feDisplacementMap in="SourceGraphic" in2="map" scale="36" xChannelSelector="R" yChannelSelector="G" />
</filter>
</svg>
</div>
<script>
(() => {
const RIM = 14;
const BEND = 36;
const EASE = 0.16;
const SETTLE = 0.5;
let lenses = 0;
function lensMap(w, h) {
const r = h / 2;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}"><defs><linearGradient id="x"><stop offset="0" stop-color="red"/><stop offset="1" stop-color="black"/></linearGradient><linearGradient id="y" x2="0" y2="1"><stop offset="0" stop-color="lime"/><stop offset="1" stop-color="black"/></linearGradient><filter id="s"><feGaussianBlur stdDeviation="${RIM / 2}"/></filter></defs><rect width="${w}" height="${h}" fill="black"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#x)"/><rect width="${w}" height="${h}" rx="${r}" fill="url(#y)" style="mix-blend-mode:screen"/><rect x="${RIM}" y="${RIM}" width="${w - RIM * 2}" height="${h - RIM * 2}" rx="${r - RIM}" fill="gray" filter="url(#s)"/></svg>`;
return 'data:image/svg+xml,' + encodeURIComponent(svg);
}
function refracts() {
return CSS.supports('backdrop-filter', 'url(#a)') && 'userAgentData' in navigator;
}
function glass(root) {
const button = root.querySelector('.glass');
const glow = root.querySelector('.glow');
const filter = root.querySelector('filter');
const map = root.querySelector('feImage');
const bend = root.querySelector('feDisplacementMap');
const speed = Number(root.dataset.speed) || 1;
const intensity = Number(root.dataset.intensity) || 1;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const id = 'fl-glass-lens-' + ++lenses;
const target = { x: 0, y: 0 };
const at = { x: 0, y: 0 };
let hovering = false;
let frame = 0;
filter.id = id;
root.style.setProperty('--spin', 6 / speed + 's');
root.style.setProperty('--glow', String(Math.min(1, 0.9 * intensity)));
bend.setAttribute('scale', String(BEND * intensity));
function resize() {
const w = Math.round(button.offsetWidth);
const h = Math.round(button.offsetHeight);
map.setAttribute('width', String(w));
map.setAttribute('height', String(h));
map.setAttribute('href', lensMap(w, h));
}
function paint() {
root.style.setProperty('--gx', at.x + 'px');
root.style.setProperty('--gy', at.y + 'px');
root.style.setProperty('--fx', at.x + glow.offsetLeft - button.offsetLeft + 'px');
root.style.setProperty('--fy', at.y + glow.offsetTop - button.offsetTop + 'px');
}
function step() {
const k = Math.min(1, EASE * speed);
at.x += (target.x - at.x) * k;
at.y += (target.y - at.y) * k;
paint();
if (Math.abs(target.x - at.x) + Math.abs(target.y - at.y) < SETTLE) {
frame = 0;
return;
}
frame = requestAnimationFrame(step);
}
function aim(x, y, move) {
target.x = x;
target.y = y;
if (move === 'jump' || still.matches) {
at.x = x;
at.y = y;
paint();
return;
}
if (!frame) {
frame = requestAnimationFrame(step);
}
}
function aimAt(event, move) {
const box = glow.getBoundingClientRect();
const face = button.getBoundingClientRect();
root.style.setProperty('--mx', ((event.clientX - face.left) / face.width) * 100 + '%');
root.style.setProperty('--my', ((event.clientY - face.top) / face.height) * 100 + '%');
aim(event.clientX - box.left, event.clientY - box.top, move);
}
function aimCentre() {
aim(glow.offsetWidth / 2, glow.offsetHeight / 2, 'jump');
}
function showFocus() {
aimCentre();
root.setAttribute('data-lit', 'focus');
}
function onEnter(event) {
if (event.pointerType === 'touch') {
return;
}
aimAt(event, root.getAttribute('data-lit') === 'pointer' ? 'ease' : 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onDown(event) {
if (event.pointerType !== 'touch') {
return;
}
aimAt(event, 'jump');
hovering = true;
root.setAttribute('data-lit', 'pointer');
}
function onMove(event) {
if (!hovering) {
return;
}
aimAt(event, 'ease');
}
function onLeave() {
hovering = false;
root.style.setProperty('--mx', '50%');
root.style.setProperty('--my', '0%');
if (button.matches(':focus-visible')) {
showFocus();
return;
}
root.removeAttribute('data-lit');
}
function onUp(event) {
if (event.pointerType === 'touch') {
onLeave();
}
}
function onFocus() {
if (hovering || !button.matches(':focus-visible')) {
return;
}
showFocus();
}
function onBlur() {
if (hovering) {
return;
}
root.removeAttribute('data-lit');
}
const watch = new ResizeObserver(resize);
const events = [
[root, 'pointerenter', onEnter],
[root, 'pointerdown', onDown],
[root, 'pointermove', onMove],
[root, 'pointerleave', onLeave],
[root, 'pointerup', onUp],
[root, 'pointercancel', onLeave],
[button, 'focus', onFocus],
[button, 'blur', onBlur]
];
if (refracts()) {
root.style.setProperty('--lens', 'url(#' + id + ')');
root.setAttribute('data-lens', '');
watch.observe(button);
}
events.forEach(([el, type, fn]) => el.addEventListener(type, fn));
return () => {
cancelAnimationFrame(frame);
watch.disconnect();
events.forEach(([el, type, fn]) => el.removeEventListener(type, fn));
root.removeAttribute('data-lens');
root.removeAttribute('data-lit');
};
}
document.querySelectorAll('.fl-glass-button:not([data-ready])').forEach((root) => {
root.setAttribute('data-ready', '');
glass(root);
});
})();
</script>
.fl-glass-button{font-family:var(--feega-font);font-size:var(--feega-text-body);line-height:1.5;letter-spacing:var(--feega-tracking);color:var(--feega-fg);background:var(--feega-bg);-webkit-font-smoothing:antialiased}
:where(.fl-glass-button) *,:where(.fl-glass-button) *::before,:where(.fl-glass-button) *::after{box-sizing:border-box}
:where(.fl-glass-button) :is(h1,h2,h3,h4,p,ul,ol,figure,blockquote,dl,dd){margin:0}
:where(.fl-glass-button) a{color:inherit;text-decoration:none}
:where(.fl-glass-button) :focus-visible{outline:2px solid var(--feega-focus);outline-offset:3px}
.fl-glass-button{--glow-1:deeppink;--glow-2:orange;--glow-3:gold;--glow-4:springgreen;--glow-5:deepskyblue;--glow-6:blueviolet;--shine:white;--spin:6s;--radius:var(--feega-radius-full);--blur:12px;--glow:0.9;--fade:300ms;--mx:50%;--my:0%;--gx:50%;--gy:50%;--fx:50%;--fy:50%;position:relative;display:inline-grid;place-items:center;padding:var(--feega-space-12) var(--feega-space-16);max-width:100%}
.fl-glass-button .glow{position:absolute;inset:calc(var(--feega-space-12) - 8px) calc(var(--feega-space-16) - 8px);filter:blur(var(--blur));opacity:0;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .hue{position:absolute;inset:0;background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1)) 0 0/200% 100%;opacity:0.4;-webkit-mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);mask:radial-gradient(ellipse 55% 45% at var(--gx) var(--gy),black,transparent);animation:fl-glass-spin var(--spin) linear infinite}
@keyframes fl-glass-spin{to{background-position:200% 0}}
.fl-glass-button[data-lit] .glow{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .glow{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .glass{position:relative;display:inline-flex;align-items:center;justify-content:center;min-height:56px;max-width:100%;padding:0 var(--feega-space-8);border:0;border-radius:var(--radius);background:linear-gradient(180deg,color-mix(in srgb,var(--feega-raised) 30%,transparent),color-mix(in srgb,var(--feega-raised) 8%,transparent));color:var(--feega-fg);font:inherit;font-size:1.0625rem;font-weight:500;letter-spacing:var(--feega-tracking);white-space:nowrap;cursor:pointer;-webkit-backdrop-filter:blur(8px) saturate(1.6);backdrop-filter:blur(8px) saturate(1.6);box-shadow:inset 0 1px 0 color-mix(in srgb,var(--shine) 80%,transparent),inset 0 -1px 0 color-mix(in srgb,var(--shine) 25%,transparent),inset 0 -12px 20px -12px color-mix(in srgb,var(--feega-fg) 22%,transparent),inset 1px 0 0 color-mix(in srgb,var(--glow-5) 22%,transparent),inset -1px 0 0 color-mix(in srgb,var(--glow-1) 22%,transparent),0 0 0 1px color-mix(in srgb,var(--feega-fg) 8%,transparent),0 8px 24px -12px color-mix(in srgb,var(--feega-fg) 30%,transparent);transition:transform var(--feega-dur-fast) var(--feega-ease)}
.fl-glass-button[data-lens] .glass{-webkit-backdrop-filter:var(--lens) blur(1.5px) saturate(1.6);backdrop-filter:var(--lens) blur(1.5px) saturate(1.6)}
.fl-glass-button .glass::before{content:"";position:absolute;inset:0;padding:1.5px;border-radius:inherit;background:radial-gradient(90% 130% at var(--mx) var(--my),var(--shine),transparent 70%);-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);pointer-events:none}
.fl-glass-button .glass::after{content:"";position:absolute;inset:0;border-radius:inherit;background:radial-gradient(60% 90% at var(--mx) var(--my),color-mix(in srgb,var(--shine) 40%,transparent),transparent 70%);opacity:0.3;pointer-events:none;transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .light{position:absolute;inset:-8px;opacity:0;pointer-events:none;-webkit-mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);mask:radial-gradient(ellipse 75% 150% at calc(var(--fx) + 8px) calc(var(--fy) + 8px),black,color-mix(in srgb,black 35%,transparent) 40%,transparent);transition:opacity var(--fade) var(--feega-ease)}
.fl-glass-button .halo{position:absolute;inset:0;filter:blur(5px);opacity:0.8}
.fl-glass-button .ring{position:absolute;inset:8px;padding:1.5px;border-radius:var(--radius);background:conic-gradient(from 90deg at var(--fx) var(--fy),var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));-webkit-mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0);mask:linear-gradient(black 0 0) content-box exclude,linear-gradient(black 0 0)}
.fl-glass-button .halo .ring{padding:5px}
.fl-glass-button .tint{position:absolute;inset:8px;border-radius:var(--radius);background:linear-gradient(90deg,var(--glow-1),var(--glow-2),var(--glow-3),var(--glow-4),var(--glow-5),var(--glow-6),var(--glow-1));opacity:0.12;filter:blur(6px)}
.fl-glass-button[data-lit] .light{opacity:var(--glow)}
.fl-glass-button[data-lit="focus"] .light{opacity:calc(var(--glow) * 0.6)}
.fl-glass-button .label{position:relative;z-index:1;text-shadow:0 1px 1px color-mix(in srgb,var(--feega-bg) 45%,transparent)}
.fl-glass-button .lens{position:absolute;width:0;height:0;overflow:hidden}
.fl-glass-button[data-lit] .glass::after{opacity:0.6}
.fl-glass-button .glass:active{transform:scale(0.97,0.93)}
@media (prefers-reduced-motion:reduce){.fl-glass-button .hue{animation:none}.fl-glass-button .glow,.fl-glass-button .light{transition:none}}
@media (prefers-reduced-motion:reduce){:where([class^="fl-"]) *,:where([class^="fl-"]) *::before,:where([class^="fl-"]) *::after{animation:none!important;transition:none!important}}
tokens.css, the shared file every template reads
:root,
[data-theme="light"] {
color-scheme: light;
--feega-bg: #f7f6f2;
--feega-surface: #efede7;
--feega-raised: #ffffff;
--feega-input: #ffffff;
--feega-fg: #121212;
--feega-fg-muted: #5c5a55;
--feega-fg-subtle: #6d6a63;
--feega-line: #e2dfd7;
--feega-line-strong: #cdc9bf;
--feega-dot: #d3cfc5;
--feega-accent: #ff4f00;
--feega-accent-hover: #ff6a26;
--feega-accent-fg: #121212;
--feega-accent-soft: #ffe8dc;
--feega-accent-text: #b83800;
--feega-danger: #c0231a;
--feega-danger-fg: #ffffff;
--feega-danger-soft: #fde6e3;
--feega-success: #12703a;
--feega-success-soft: #e0f3e6;
--feega-focus: #ff4f00;
--feega-overlay: rgb(18 18 18 / 0.4);
--feega-shadow: 0 1px 2px rgb(18 18 18 / 0.05), 0 8px 24px -8px rgb(18 18 18 / 0.12);
--feega-shadow-float: 0 2px 4px rgb(18 18 18 / 0.06), 0 24px 48px -12px rgb(18 18 18 / 0.22);
--feega-radius-xs: 2px;
--feega-radius-sm: 6px;
--feega-radius-md: 10px;
--feega-radius-lg: 16px;
--feega-radius-full: 999px;
--feega-font: "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--feega-font-display: var(--feega-font);
--feega-font-mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
--feega-tracking: -0.02em;
--feega-tracking-tight: -0.05em;
--feega-text-xs: 0.75rem;
--feega-text-sm: 0.875rem;
--feega-text-body: 1rem;
--feega-text-lg: clamp(1.0625rem, 1.6vw, 1.25rem);
--feega-text-xl: 1.5rem;
--feega-text-title: clamp(2.5rem, 6vw, 4.5rem);
--feega-text-display: clamp(3rem, 9.5vw, 7rem);
--feega-ease: cubic-bezier(0.16, 1, 0.3, 1);
--feega-dur-fast: 160ms;
--feega-dur: 420ms;
--feega-space-1: 0.25rem;
--feega-space-2: 0.5rem;
--feega-space-3: 0.75rem;
--feega-space-4: 1rem;
--feega-space-6: 1.5rem;
--feega-space-8: 2rem;
--feega-space-12: 3rem;
--feega-space-16: 4rem;
--feega-space-section: clamp(4.5rem, 11vw, 9rem);
--feega-gutter: clamp(1rem, 4vw, 2rem);
--feega-max-width: 76rem;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
color-scheme: dark;
--feega-bg: #050505;
--feega-surface: #121212;
--feega-raised: #1a1a1a;
--feega-input: #0d0d0d;
--feega-fg: #f0eee9;
--feega-fg-muted: #a3a09a;
--feega-fg-subtle: #8a877f;
--feega-line: #232323;
--feega-line-strong: #363636;
--feega-dot: #2c2c2c;
--feega-accent: #ff5a14;
--feega-accent-hover: #ff7333;
--feega-accent-fg: #121212;
--feega-accent-soft: #2b1206;
--feega-accent-text: #ff7a3d;
--feega-danger: #ff6b5e;
--feega-danger-fg: #121212;
--feega-danger-soft: #2e0f0c;
--feega-success: #4cc47a;
--feega-success-soft: #0d2617;
--feega-focus: #ff5a14;
--feega-overlay: rgb(0 0 0 / 0.7);
--feega-shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 24px -8px rgb(0 0 0 / 0.6);
--feega-shadow-float: 0 2px 4px rgb(0 0 0 / 0.5), 0 24px 48px -12px rgb(0 0 0 / 0.8);
}
}
[data-theme="dark"] {
color-scheme: dark;
--feega-bg: #050505;
--feega-surface: #121212;
--feega-raised: #1a1a1a;
--feega-input: #0d0d0d;
--feega-fg: #f0eee9;
--feega-fg-muted: #a3a09a;
--feega-fg-subtle: #8a877f;
--feega-line: #232323;
--feega-line-strong: #363636;
--feega-dot: #2c2c2c;
--feega-accent: #ff5a14;
--feega-accent-hover: #ff7333;
--feega-accent-fg: #121212;
--feega-accent-soft: #2b1206;
--feega-accent-text: #ff7a3d;
--feega-danger: #ff6b5e;
--feega-danger-fg: #121212;
--feega-danger-soft: #2e0f0c;
--feega-success: #4cc47a;
--feega-success-soft: #0d2617;
--feega-focus: #ff5a14;
--feega-overlay: rgb(0 0 0 / 0.7);
--feega-shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 8px 24px -8px rgb(0 0 0 / 0.6);
--feega-shadow-float: 0 2px 4px rgb(0 0 0 / 0.5), 0 24px 48px -12px rgb(0 0 0 / 0.8);
}
what it is
Glass button is a free component. A clear liquid glass pill button; a rainbow light follows the cursor and bends through the glass. It is tagged button, glass, glow and animation.
It has behaviour: a few lines of script in the plain HTML version, and framework state in the Svelte, React and Vue versions.
Size per version: Svelte 1 file, 231 lines; React 2 files, 232 lines; Vue 1 file, 237 lines; Astro 1 file, 233 lines; HTML 2 files, 230 lines.
tokens this template reads
| Token | Controls | Uses |
|---|---|---|
| --feega-fg | main text | 5 |
| --feega-ease | the animation curve | 4 |
| --feega-bg | the page background | 2 |
| --feega-raised | cards and raised surfaces | 2 |
| --feega-space-12 | spacing step 12 | 2 |
| --feega-space-16 | spacing step 16 | 2 |
| --feega-tracking | letter spacing for body text | 2 |
| --feega-dur-fast | the short animation duration | 1 |
| --feega-focus | the keyboard focus ring | 1 |
| --feega-font | the body typeface | 1 |
| --feega-radius-full | fully round pills and buttons | 1 |
| --feega-space-8 | spacing step 8 | 1 |
To restyle it, set any of these custom properties on :root, or on an ancestor of the template to change it in one place only. For example, --feega-accent changes the brand colour in light and dark alike. Add the shared tokens.css once per project.
fonts
It uses Inter Tight (400, 500, 600) from Google Fonts. Without them the font tokens fall back to a system stack.
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600&display=swap" />insert with Feega
Open Add, then Library, and click Insert or drag it into your running app. Feega writes the component, tokens and fonts for your framework. One undo. how it works
Free VS Code extension. No account, no AI.
get feega →