Tarjeta liquid glass
Panel de vidrio con borde especular, brillo que sigue al puntero y ligera inclinación 3D, al estilo de iOS 26.
Ventas de hoy
$48,260
12% más que ayer
- Pedidos86
- Ticket medio$561
- Devoluciones2
Prueba el material con el puntero, al pulsar y con el teclado.
Código completo
Es exactamente el archivo que se descarga. Cópialo a tu proyecto y úsalo.
"use client";
import { createElement, useCallback, useEffect, useId, useState, useSyncExternalStore, type CSSProperties, type PointerEvent, type ReactNode } from "react";
/** Tarjeta liquid glass: panel de cristal con grosor, borde óptico que refracta el fondo, reflejos que siguen al puntero y una inclinación apenas perceptible. Variantes regular y clear; esquemas dark y light. React + TypeScript, sin dependencias. */
export type TarjetaLiquidGlassProps = {
title?: string;
value?: string;
caption?: string;
items?: { label: string; value: string }[];
/** Regular suaviza el fondo para leer mejor; clear deja pasar casi todo. */
variant?: "regular" | "clear";
/** Dark para fondos oscuros o con color; light para fondos claros. */
scheme?: "dark" | "light";
className?: string;
style?: CSSProperties;
};
const CSS = `
.gctlg-root { box-sizing: border-box; display: block; width: 100%; max-width: 330px; perspective: 1000px; font: 500 15px/1.4 -apple-system, "SF Pro Display", ui-sans-serif, system-ui, sans-serif; color: var(--gctlg-fg, #fff); }
.gctlg-root[data-s="light"] { --gctlg-fg: #14193d; }
.gctlg-root *, .gctlg-root *::before, .gctlg-root *::after { box-sizing: border-box; }
@property --gctlg-a { syntax: "<angle>"; inherits: true; initial-value: 135deg; }
@property --gctlg-p { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --gctlg-sx { syntax: "<percentage>"; inherits: true; initial-value: 24%; }
@property --gctlg-sy { syntax: "<percentage>"; inherits: true; initial-value: 8%; }
@property --gctlg-hi { syntax: "<number>"; inherits: true; initial-value: .78; }
@property --gctlg-tc { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --gctlg-te { syntax: "<color>"; inherits: true; initial-value: transparent; }
.gctlg-g, .gctlg-gf {
--gctlg-a: 135deg; --gctlg-p: 0deg; --gctlg-sx: 24%; --gctlg-sy: 8%;
--gctlg-bl: var(--gctlg-blur, 2.6px); --gctlg-tc: rgba(255,255,255,.025); --gctlg-te: rgba(255,255,255,.12);
--gctlg-sh: rgba(12,16,24,.16); --gctlg-hi: .78; --gctlg-ink: 12,16,24; --gctlg-ins: 3px;
--gctlg-contact: .14; --gctlg-ambient: .2;
position: relative; isolation: isolate; border: 0; color: var(--gctlg-fg, #fff);
background: radial-gradient(115% 120% at 50% 40%, var(--gctlg-tc) 42%, var(--gctlg-te) 100%), linear-gradient(var(--gctlg-sh),var(--gctlg-sh));
-webkit-backdrop-filter: blur(var(--gctlg-bl)) saturate(1.08) brightness(1.02);
backdrop-filter: blur(var(--gctlg-bl)) saturate(1.08) brightness(1.02);
box-shadow: inset .5px 1px 1px rgba(255,255,255,.42), inset -.5px -1px 1.5px rgba(255,255,255,.16), inset 2px 3px 7px -5px rgba(255,255,255,.45), inset -2px -4px 8px -5px rgba(var(--gctlg-ink),.26), 0 1px 2px rgba(var(--gctlg-ink),var(--gctlg-contact)), 0 12px 28px -10px rgba(var(--gctlg-ink),var(--gctlg-ambient));
transition: --gctlg-a 280ms cubic-bezier(.16,1,.3,1), --gctlg-p 320ms cubic-bezier(.22,1.08,.36,1), --gctlg-sx 240ms cubic-bezier(.16,1,.3,1), --gctlg-sy 240ms cubic-bezier(.16,1,.3,1), --gctlg-hi 180ms ease-out, --gctlg-tc 180ms ease-out, --gctlg-te 180ms ease-out, box-shadow 240ms ease-out, transform 360ms cubic-bezier(.22,1.08,.36,1);
}
.gctlg-g[data-v="clear"], .gctlg-gf[data-v="clear"] { --gctlg-bl: var(--gctlg-clear-blur,.45px); --gctlg-tc: rgba(255,255,255,.008); --gctlg-te: rgba(255,255,255,.065); --gctlg-sh: rgba(12,16,24,.07); }
.gctlg-root[data-s="light"] :is(.gctlg-g,.gctlg-gf), .gctlg-g[data-s="light"], .gctlg-gf[data-s="light"] { --gctlg-tc: rgba(255,255,255,.06); --gctlg-te: rgba(255,255,255,.18); --gctlg-sh: rgba(255,255,255,.025); --gctlg-ink: 24,30,38; --gctlg-fg: #17202b; --gctlg-contact: .09; --gctlg-ambient: .13; }
.gctlg-root[data-s="light"] :is(.gctlg-g,.gctlg-gf)[data-v="clear"], .gctlg-g[data-s="light"][data-v="clear"], .gctlg-gf[data-s="light"][data-v="clear"] { --gctlg-tc: rgba(255,255,255,.015); --gctlg-te: rgba(255,255,255,.085); }
/* Nested controls share their parent's optical plane; never blur glass twice. */
.gctlg-gf { -webkit-backdrop-filter: none; backdrop-filter: none; --gctlg-tc: rgba(255,255,255,.04); --gctlg-te: rgba(255,255,255,.12); --gctlg-sh: transparent; }
.gctlg-g[data-r="1"] { backdrop-filter: blur(var(--gctlg-bl)) var(--gctlg-f) saturate(1.08) brightness(1.02); }
.gctlg-g[data-t="solid"], .gctlg-gf[data-t="solid"] { --gctlg-tc: rgba(255,255,255,.19); --gctlg-te: rgba(255,255,255,.32); --gctlg-sh: rgba(12,16,24,.2); font-weight: 650; }
.gctlg-g[data-t="solid"][data-s="light"], .gctlg-gf[data-t="solid"][data-s="light"] { --gctlg-sh: rgba(255,255,255,.08); }
.gctlg-g::before, .gctlg-gf::before { content: ""; position: absolute; inset: 0; z-index: 3; padding: .8px; border-radius: inherit; pointer-events: none; opacity: var(--gctlg-hi);
background: conic-gradient(from calc(var(--gctlg-a) + var(--gctlg-p)), rgba(255,255,255,.04), rgba(255,255,255,.06) 12%, rgba(255,255,255,.88) 21%, rgba(255,255,255,.16) 28%, rgba(255,255,255,.025) 42%, rgba(255,255,255,.04) 60%, rgba(255,255,255,.62) 72%, rgba(255,255,255,.13) 79%, rgba(255,255,255,.04));
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
.gctlg-g::after, .gctlg-gf::after { content: ""; position: absolute; inset: var(--gctlg-ins); z-index: -1; border-radius: max(0px,calc(var(--gctlg-r,24px) - var(--gctlg-ins))); pointer-events: none; opacity: .55; transition: opacity 180ms ease-out;
background: radial-gradient(38% 24% at var(--gctlg-sx) var(--gctlg-sy), rgba(255,255,255,.22), transparent 75%), radial-gradient(30% 18% at 84% 98%, rgba(255,255,255,.085), transparent 75%);
box-shadow: inset .5px 1px 1px rgba(255,255,255,.15), inset -.5px -1px 2px rgba(var(--gctlg-ink),.12);
}
.gctlg-root[data-s="light"] :is(.gctlg-g,.gctlg-gf)::before, .gctlg-g[data-s="light"]::before, .gctlg-gf[data-s="light"]::before { background: conic-gradient(from calc(var(--gctlg-a) + var(--gctlg-p)), rgba(var(--gctlg-ink),.08), rgba(255,255,255,.3) 12%, #fff 21%, rgba(255,255,255,.25) 28%, rgba(var(--gctlg-ink),.13) 45%, rgba(var(--gctlg-ink),.03) 60%, rgba(255,255,255,.95) 72%, rgba(255,255,255,.3) 79%, rgba(var(--gctlg-ink),.08)); }
.gctlg-g[data-e="2"] { --gctlg-contact: .17; --gctlg-ambient: .25; box-shadow: inset .5px 1px 1px rgba(255,255,255,.5), inset -.5px -1px 2px rgba(255,255,255,.2), inset 2px 3px 8px -5px rgba(255,255,255,.45), inset -2px -5px 10px -6px rgba(var(--gctlg-ink),.24), 0 2px 4px rgba(var(--gctlg-ink),var(--gctlg-contact)), 0 24px 52px -18px rgba(var(--gctlg-ink),var(--gctlg-ambient)); }
.gctlg-g[data-i], .gctlg-gf[data-i] { cursor: pointer; touch-action: manipulation; }
.gctlg-g:focus-visible, .gctlg-gf:focus-visible { outline: 2px solid var(--gctlg-fg,#fff); outline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
.gctlg-g[data-i]:hover:not(:disabled), .gctlg-gf[data-i]:hover:not(:disabled) { --gctlg-hi: .98; }
.gctlg-g[data-i]:hover:not(:disabled)::after, .gctlg-gf[data-i]:hover:not(:disabled)::after { opacity: .85; }
.gctlg-g[data-t="solid"][data-i]:hover:not(:disabled), .gctlg-gf[data-t="solid"][data-i]:hover:not(:disabled) { --gctlg-tc: rgba(255,255,255,.25); }
}
.gctlg-g[data-i]:active:not(:disabled), .gctlg-gf[data-i]:active:not(:disabled) { --gctlg-p: 14deg; --gctlg-hi: 1; transform: scale(.985,.97); transition-duration: 80ms; }
.gctlg-g[data-i]:active:not(:disabled)::after, .gctlg-gf[data-i]:active:not(:disabled)::after { opacity: .95; }
.gctlg-g:disabled, .gctlg-gf:disabled { cursor: not-allowed; }
.gctlg-svg { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
.gctlg-g { background: rgba(30,36,46,.9); }
.gctlg-root[data-s="light"] .gctlg-g, .gctlg-g[data-s="light"] { background: rgba(245,247,250,.94); }
}
@media (prefers-reduced-transparency: reduce) { .gctlg-g, .gctlg-gf { background: #26303d; color: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; } .gctlg-root[data-s="light"] :is(.gctlg-g,.gctlg-gf), .gctlg-g[data-s="light"], .gctlg-gf[data-s="light"] { background: #f2f5f8; color: #17202b; } }
@media (prefers-reduced-motion: reduce) {
.gctlg-root *, .gctlg-root *::before, .gctlg-root *::after { animation: none !important; transition-duration: .01ms !important; }
.gctlg-g[data-i]:active:not(:disabled), .gctlg-gf[data-i]:active:not(:disabled) { transform: none; }
}
@media (forced-colors: active) { .gctlg-g, .gctlg-gf { border: 1px solid CanvasText; background: Canvas; color: CanvasText; -webkit-backdrop-filter: none; backdrop-filter: none; } .gctlg-g::before, .gctlg-g::after, .gctlg-gf::before, .gctlg-gf::after { display: none; } }
.gctlg-card { --gctlg-rx: 0deg; --gctlg-ry: 0deg; padding: 24px; border-radius: 34px; transform: rotateX(var(--gctlg-rx)) rotateY(var(--gctlg-ry)); transition: --gctlg-a .7s cubic-bezier(.16, 1, .3, 1), transform .6s cubic-bezier(.16, 1, .3, 1), box-shadow .35s, background .35s; text-shadow: 0 1px 2px rgba(10, 10, 50, .28); }
.gctlg-card[data-s="light"] { text-shadow: none; }
.gctlg-card[data-live="true"] { transition-duration: 280ms, 160ms, 240ms, 180ms; }
.gctlg-root .gctlg-title { color: inherit; margin: 0; font-size: 14px; font-weight: 600; opacity: .9; }
.gctlg-root .gctlg-value { margin: 4px 0 2px; font: 700 54px/1 -apple-system, "SF Pro Display", ui-sans-serif, sans-serif; letter-spacing: -.03em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.gctlg-root .gctlg-cap { color: inherit; margin: 0 0 18px; font-size: 14px; opacity: .9; }
.gctlg-rows { display: grid; gap: 8px; margin: 0; padding: 14px 0 0; list-style: none; border-top: 1px solid rgba(255, 255, 255, .22); box-shadow: inset 0 1px 0 rgba(8, 6, 40, .08); }
.gctlg-rows li { display: flex; justify-content: space-between; gap: 16px; overflow-wrap: anywhere; font-size: 14px; }
.gctlg-rows b { font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .gctlg-card { transform: none; } }`;
/* Motor de vidrio líquido: mapa de desplazamiento por borde (refracción) + dispersión leve, calculado a la medida de cada pieza. */
const noop = () => () => {};
const canRefract = () => typeof window !== "undefined" && typeof window.CSS !== "undefined" && window.CSS.supports("backdrop-filter", "url(#a)") && /Chrome\//.test(navigator.userAgent);
const bend = (t: number) => {
const u = 1 - t;
const th = Math.atan(Math.pow(Math.max(1 - u * u * u * u, 1e-6), -0.75) * u * u * u * 0.9);
return Math.sin(th - Math.asin(Math.sin(th) / 1.5));
};
const PEAK = bend(0.02);
/** Mapa R/G de desplazamiento: 0 en el centro, máximo en el borde (perfil de cristal convexo y ley de Snell, n = 1.5). */
const mapCache = new Map<string, string>();
function glassMap(w: number, h: number, r: number, bezel: number): string {
const key = [w, h, r, bezel].join(":");
const cached = mapCache.get(key);
if (cached) return cached;
const k = Math.min(1, Math.sqrt(90000 / (w * h)));
const cw = Math.max(2, Math.round(w * k));
const ch = Math.max(2, Math.round(h * k));
const canvas = document.createElement("canvas");
canvas.width = cw;
canvas.height = ch;
const ctx = canvas.getContext("2d");
if (!ctx) return "";
const img = ctx.createImageData(cw, ch);
const hx = w / 2;
const hy = h / 2;
for (let j = 0; j < ch; j++) {
for (let i = 0; i < cw; i++) {
const px = (i + 0.5) * w / cw - hx;
const py = (j + 0.5) * h / ch - hy;
const qx = Math.abs(px) - (hx - r);
const qy = Math.abs(py) - (hy - r);
let nx = 0;
let ny = 0;
let d: number;
if (qx > 0 && qy > 0) {
const l = Math.hypot(qx, qy);
d = r - l;
nx = qx / l;
ny = qy / l;
} else if (qx > qy) {
d = hx - Math.abs(px);
nx = 1;
} else {
d = hy - Math.abs(py);
ny = 1;
}
const t = d / bezel;
const m = t >= 1 ? 0 : Math.min(1, bend(Math.max(t, 0.02)) / PEAK);
const o = (j * cw + i) * 4;
img.data[o] = 128 - (Math.sign(px) || 1) * nx * m * 127;
img.data[o + 1] = 128 - (Math.sign(py) || 1) * ny * m * 127;
img.data[o + 2] = 128;
img.data[o + 3] = 255;
}
}
ctx.putImageData(img, 0, 0);
const map = canvas.toDataURL();
if (mapCache.size >= 24) mapCache.delete(mapCache.keys().next().value!);
mapCache.set(key, map);
return map;
}
type SurfaceProps = {
as?: string;
/** Radio de las esquinas en px; por defecto el que resuelve el CSS. */
radius?: number;
/** Ancho de la franja que refracta, en px. */
bezel?: number;
/** Desplazamiento máximo del fondo en el borde, en px. */
depth?: number;
variant?: "regular" | "clear";
/** Solid: mayor contraste para la acción principal, conservando transparencia. */
tone?: "solid";
scheme?: "dark" | "light";
elevated?: boolean;
flat?: boolean;
interactive?: boolean;
elRef?: (node: HTMLElement | null) => void;
className?: string;
style?: CSSProperties;
children?: ReactNode;
onPointerMove?: (event: PointerEvent<HTMLElement>) => void;
onPointerLeave?: (event: PointerEvent<HTMLElement>) => void;
[prop: string]: unknown;
};
/** Superficie de vidrio: refracta el fondo en Chromium (SVG + backdrop-filter) y cae a vidrio con desenfoque en el resto; el borde óptico, el volumen y las sombras no dependen del filtro. */
function Surface({ as = "div", radius, bezel, depth, variant = "regular", tone, scheme = "dark", elevated, flat, interactive, elRef, className = "", style, children, onPointerMove, onPointerLeave, ...rest }: SurfaceProps) {
const id = `gctlg-f-${useId().replace(/[^a-zA-Z0-9]/g, "")}
@media (prefers-reduced-motion: reduce) { .gctlg-card { transform: none; } }`;
const refract = useSyncExternalStore(noop, canRefract, () => false) && !flat;
const [node, setNode] = useState<HTMLElement | null>(null);
const [lens, setLens] = useState<{ w: number; h: number; r: number; depth: number; map: string } | null>(null);
const bind = useCallback(
(el: HTMLElement | null) => {
setNode(el);
elRef?.(el);
},
[elRef],
);
useEffect(() => {
if (!node || !refract) return;
let lw = 0;
let lh = 0;
let frame = 0;
const measure = () => {
const w = node.offsetWidth;
const h = node.offsetHeight;
if (!w || !h || (w === lw && h === lh)) return;
lw = w;
lh = h;
const corner = getComputedStyle(node).borderTopLeftRadius;
const resolved = corner.endsWith("%") ? parseFloat(corner) / 100 * Math.min(w, h) : parseFloat(corner) || 0;
const r = Math.min(radius ?? resolved, w / 2, h / 2);
const bz = Math.max(6, Math.min(bezel ?? Math.min(w, h) * 0.24, Math.min(w, h) / 2, 48));
const map = glassMap(w, h, r, bz);
setLens(map ? { w, h, r, depth: (depth ?? Math.round(bz * .85)) * (variant === "clear" ? 1 : .85), map } : null);
};
const observer = new ResizeObserver(() => {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(measure);
});
observer.observe(node);
return () => { observer.disconnect(); cancelAnimationFrame(frame); };
}, [node, refract, radius, bezel, depth, variant]);
const live = refract && lens;
const move = (event: PointerEvent<HTMLElement>) => {
if (event.pointerType !== "touch" && !event.currentTarget.matches(":disabled") && !window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
const box = event.currentTarget.getBoundingClientRect();
const x = Math.max(0, Math.min(1, (event.clientX - box.left) / box.width));
const y = Math.max(0, Math.min(1, (event.clientY - box.top) / box.height));
event.currentTarget.style.setProperty("--gctlg-a", `${135 + (x - 0.5) * 40 - (y - 0.5) * 18}deg`);
event.currentTarget.style.setProperty("--gctlg-sx", `${18 + x * 64}%`);
event.currentTarget.style.setProperty("--gctlg-sy", `${3 + y * 12}%`);
}
onPointerMove?.(event);
};
const leave = (event: PointerEvent<HTMLElement>) => {
for (const name of ["a", "sx", "sy"]) event.currentTarget.style.removeProperty(`--gctlg-${name}`);
onPointerLeave?.(event);
};
return createElement(
as,
{
...rest,
ref: bind,
className: `gctlg-${flat ? "gf" : "g"} ${className}`,
"data-v": variant,
"data-s": scheme,
"data-t": tone,
"data-r": live ? "1" : undefined,
"data-e": elevated ? "2" : undefined,
"data-i": interactive ? "1" : undefined,
style: { ...style, "--gctlg-r": live ? `${lens.r}px` : radius !== undefined ? `${radius}px` : undefined, "--gctlg-f": live ? `url(#${id})` : undefined } as CSSProperties,
onPointerMove: move,
onPointerLeave: leave,
},
live ? (
<svg className="gctlg-svg" aria-hidden="true" focusable="false">
<filter id={id} filterUnits="userSpaceOnUse" x={-lens.depth} y={-lens.depth} width={lens.w + lens.depth * 2} height={lens.h + lens.depth * 2} colorInterpolationFilters="sRGB">
<feImage href={lens.map} x={0} y={0} width={lens.w} height={lens.h} preserveAspectRatio="none" result="m" />
<feDisplacementMap in="SourceGraphic" in2="m" scale={lens.depth * 1.012} xChannelSelector="R" yChannelSelector="G" result="dr" />
<feColorMatrix in="dr" type="matrix" values="1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1" result="cr" />
<feDisplacementMap in="SourceGraphic" in2="m" scale={lens.depth} xChannelSelector="R" yChannelSelector="G" result="dg" />
<feColorMatrix in="dg" type="matrix" values="0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1" result="cg" />
<feDisplacementMap in="SourceGraphic" in2="m" scale={lens.depth * .988} xChannelSelector="R" yChannelSelector="G" result="db" />
<feColorMatrix in="db" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1" result="cb" />
<feBlend in="cr" in2="cg" mode="screen" result="rg" />
<feBlend in="rg" in2="cb" mode="screen" />
</filter>
</svg>
) : null,
children,
);
}
export function TarjetaLiquidGlass({ title = "Ventas de hoy", value = "$48,260", caption = "12% más que ayer", items = [{ label: "Pedidos", value: "86" }, { label: "Ticket medio", value: "$561" }, { label: "Devoluciones", value: "2" }], variant = "regular", scheme = "dark", className = "", style }: TarjetaLiquidGlassProps) {
function move(event: PointerEvent<HTMLElement>) {
if (event.pointerType === "touch" || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const el = event.currentTarget;
const rect = el.getBoundingClientRect();
const x = (event.clientX - rect.left) / rect.width;
const y = (event.clientY - rect.top) / rect.height;
el.style.setProperty("--gctlg-ry", `${(x - 0.5) * 2.8}deg`);
el.style.setProperty("--gctlg-rx", `${(0.5 - y) * 2.8}deg`);
el.dataset.live = "true";
}
function leave(event: PointerEvent<HTMLElement>) {
const el = event.currentTarget;
el.style.setProperty("--gctlg-rx", "0deg");
el.style.setProperty("--gctlg-ry", "0deg");
delete el.dataset.live;
}
return (
<div className={`gctlg-root ${className}`} style={style} data-s={scheme}>
<style>{CSS}</style>
<Surface className="gctlg-card" variant={variant} scheme={scheme} elevated bezel={26} depth={26} onPointerMove={move} onPointerLeave={leave}>
<h3 className="gctlg-title">{title}</h3>
<p className="gctlg-value">{value}</p>
<p className="gctlg-cap">{caption}</p>
<ul className="gctlg-rows">
{items.map((item) => (
<li key={item.label}>
<span>{item.label}</span>
<b>{item.value}</b>
</li>
))}
</ul>
</Surface>
</div>
);
}
Úsalo en tu proyecto
Instálalo con la CLI de shadcn.
npx shadcn@latest add https://www.gassierconsulting.com/r/tarjeta-liquid-glassEjemplo de uso de Tarjeta liquid glass
Después de copiar tarjeta-liquid-glass.tsx a tu proyecto, impórtalo y colócalo donde lo necesites.
import { TarjetaLiquidGlass } from "./tarjeta-liquid-glass";
export default function Ejemplo() {
return <TarjetaLiquidGlass variant="regular" title="Ejemplo" />;
}Propiedades de TarjetaLiquidGlass
TarjetaLiquidGlass acepta 8 propiedades: todas son opcionales y tienen un valor por defecto, así que funciona sin configurar nada.
| Propiedad | Tipo | Descripción |
|---|---|---|
title? | string | Opcional. |
value? | string | Opcional. |
caption? | string | Opcional. |
items? | { label: string; value: string }[] | Opcional. |
variant? | "regular" | "clear" | Regular suaviza el fondo para leer mejor; clear deja pasar casi todo. |
scheme? | "dark" | "light" | Dark para fondos oscuros o con color; light para fondos claros. |
className? | string | Opcional. |
style? | CSSProperties | Opcional. |
Variantes disponibles
variant:regular,clearscheme:dark,light
Personaliza Tarjeta liquid glass con variables CSS
Define estas variables en el contenedor o en tu hoja de estilos para cambiar los colores sin tocar el componente. Si no las defines, se usa el valor por defecto.
| Variable | Valor por defecto |
|---|---|
--gctlg-fg | #fff |
--gctlg-blur | 2.6px |
--gctlg-clear-blur | .45px |
--gctlg-r | 24px |
Accesibilidad y rendimiento
El archivo tiene 311 líneas (19 KB) y no necesita @keyframes. Esto es lo que hace Tarjeta liquid glass por quien lo usa:
- Detecta prefers-reduced-motion y baja o quita el movimiento cuando la persona lo pide.
- Muestra un anillo de foco visible al navegar con teclado (:focus-visible).
- Expone su estado a tecnologías de apoyo con atributos aria-*.
- Reacciona al puntero con eventos pointer (ratón, lápiz y táctil).
- Anima con requestAnimationFrame, sincronizado con el refresco de pantalla.
- Usa backdrop-filter para el efecto de vidrio; en navegadores sin soporte el panel se ve sin desenfoque.
- Lee preferencias del navegador con useSyncExternalStore, sin parpadeos en la hidratación.
- Usa @property de CSS para animar valores que normalmente no se interpolan.
- Es un componente de cliente de Next.js: incluye la directiva "use client".