liquid-metal-border
它能做什么
这个技能指导 AI 智能体使用 metal-fx 包,在 React 元素周围添加带动画的金属质感 WebGL 边框。适合希望为选中或激活控件提供高级感高亮的开发者。
适用场景
- ✓当按钮、卡片或标签页被选中或激活的时候。
- ✓当高级或悬停状态需要液态金属边缘时。
- ✓当 React 项目中的金属边框需要调整或修复时。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/liquid-metal-border/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在 React 应用中为选中的价格卡片添加液态金属边框,并以普通边框作为备用。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会用金属组件包裹一个真实的可交互元素,并把它的动画与激活或选中状态绑定。静态边框保留作为备用,未激活的项目会暂停动画以节省资源。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Liquid Metal Border
Core Contract
- Use
metal-fxin React 18 or newer. - Wrap exactly one real host element such as a
button,a,div, orarticle. - Keep the host semantic and interactive.
MetalFxis visual framing, not the control. - Reserve the animated border for active, selected, focused, hovered, or primary surfaces. Do not put it around every control.
- Keep a static CSS border or focus outline as the fallback. WebGL decoration must never carry essential state by itself.
- Pause non-active instances and reduced-motion experiences.
- Test light and dark modes independently. Reflections intentionally render only in dark mode.
Inspect Before Editing
- Confirm the project uses React and has
reactandreact-domversion 18 or newer. - Find the real control, its dimensions, radius, background, border, outline, shadow, active-state source, and theme source.
- Decide whether the metal should be always visible or driven by
active,selected, hover, or focus state. - Check whether the project has a manual theme toggle. Use that state instead of
theme="auto"when it does not follow the OS. - Identify nearby elements that genuinely benefit from reflected light. Do not add reflections by default.
- Check the installed
metal-fxversion before relying on the prop surface below.
Install and Import
Install with the project's package manager:
npm install metal-fx
# pnpm add metal-fx
# yarn add metal-fx
# bun add metal-fx
Import the named React component:
import { MetalFx } from "metal-fx";
Do not import a stylesheet. The package injects its component styles. It supports ESM and CommonJS builds, is SSR-safe, and mounts the WebGL pipeline after hydration. In a Next.js App Router project, render it from a Client Component because the component uses client-side React hooks.
Baseline Button
Start with a restrained border before adding reflections or custom shader geometry:
import { MetalFx } from "metal-fx";
export function UpgradeButton() {
return (
<MetalFx
variant="button"
preset="chromatic"
theme="auto"
strength={0.85}
>
<button type="button">Upgrade to Pro</button>
</MetalFx>
);
}
The wrapper measures the child, paints the metal ring on top, and keeps the child interactive. Size the child normally with CSS, Tailwind, or inline styles.
Active-State Pattern
Keep one mounted instance and drive its intensity from real component state. Use aria-pressed, aria-selected, or the native selected-state mechanism so the visual effect is not the only signal.
"use client";
import { useEffect, useState } from "react";
import { MetalFx } from "metal-fx";
function useReducedMotion() {
const [reduced, setReduced] = useState(false);
useEffect(() => {
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
const sync = () => setReduced(query.matches);
sync();
query.addEventListener("change", sync);
return () => query.removeEventListener("change", sync);
}, []);
return reduced;
}
export function LiquidMetalToggle({
selected,
onSelect,
}: {
selected: boolean;
onSelect: () => void;
}) {
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const reducedMotion = useReducedMotion();
const highlighted = selected || hovered || focused;
return (
<MetalFx
className="liquid-metal-toggle"
variant="button"
preset="chromatic"
strength={highlighted ? 0.9 : 0.14}
paused={reducedMotion || !highlighted}
disableGlow={reducedMotion || !highlighted}
ringCssPx={selected ? 1.5 : 1}
normalizeHostStyles={false}
>
<button
type="button"
className="liquid-metal-toggle__control"
aria-pressed={selected}
onClick={onSelect}
onPointerEnter={() => setHovered(true)}
onPointerLeave={() => setHovered(false)}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
>
Auto
</button>
</MetalFx>
);
}
.liquid-metal-toggle {
background: #18181b;
border-radius: 999px;
}
.liquid-metal-toggle__control {
min-height: 40px;
padding: 0 18px;
color: #fafafa;
background: transparent;
border: 0;
border-radius: 999px;
box-shadow: none;
}
.liquid-metal-toggle__control:focus-visible {
outline: 2px solid #ffffff;
outline-offset: 3px;
}
Use paused t
常见问题
金属边框会替代按钮吗?
不会。它只是视觉上的边框,真正的按钮或链接仍然是控件本身。
为什么不给每个按钮都加?
该技能建议只用于激活、选中、聚焦或主要的表面。
在深色和浅色模式下都能用吗?
可以,但该技能要求分别测试两种模式,因为反光效果只在深色模式下才明显。
详情
作者的原始描述
Add and tune animated liquid-metal WebGL borders with the React `metal-fx` package. Use when buttons, icon controls, chips, tabs, cards, or selected surfaces need a metallic active, selected, hover, focus, or premium border; when implementing the MetalFx component from metal.jakubantalik.com; or when troubleshooting its presets, themes, strength, glow, reflections, sizing, radius, animation, accessibility, SSR, or performance.
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13446
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。