着色器发光玻璃药丸按钮
深色药丸里漂着模糊光团,上沿有亮白细边,下沿有暖色内光,左侧是八臂星图标,右侧是白字。整只按钮由一段 shader 解析绘制,悬停时光团跟随指针,按下缩小。WebGL 与 Skia 共用源码。
灵感来自 @coleHardik 在 X 上发布的设计由 Now In Code 从零重建
import { Piece } from "./components";
export function Example() {
const progress = useSharedValue(0);
…
export function Example() {
const progress = useSharedValue(0);
…
Agent 提示词
Add the Now In Code component "shader-glow-glass-pill-button" to this project. The full source is attached at the end of this prompt. Put the files under components/shader-glow-glass-pill-button/, install the listed dependencies with `npx expo install`, and render it on a route I can open. Keep the timing and easing values documented in the source comments. Replace the sample copy and artwork with content from my app, or leave placeholders and list what I still need to supply. === Source files are attached here for paid plans ===
Pro 作品。提示词包含完整源码。开始使用
详情
- 平台
- iOS、Android、Web
- 依赖
- Expo SDK 54+
- 权限
- Pro
- 更新于
- 2026年11月20日
- 许可证
- 无限商业项目
- 原始设计
- @coleHardik(X)
你是设计者吗? 请求我们修改或下架此作品.
CLI 与 MCP 服务器 即将推出
在终端添加作品,或让智能体自行获取。在此之前,用“复制提示词”也能做到。 文档
功能说明
一个宽大的深色药丸按钮,上面有简短的行动号召文字,左侧是八角星图标,右侧是白色文字。药丸内部,模糊的蓝紫色光斑缓缓漂移,上边缘有一道细亮的边缘光,下边缘有暖粉橙色的内发光。通过 variant 属性还可使用银灰色配色。指针划过按钮时,光斑会被横向拉扯,玻璃也稍微更亮;按下时按钮缩小几个百分点。静止时,按钮与静态参考图一致。
实现方式
整个按钮表面,包括玻璃底、光斑、内阴影、轮廓线,以及带柔和投影的星形,都由 Skia 画布中一个 SkSL 片段着色器绘制,它被编译为 Skia RuntimeEffect。标签是叠在其上的普通 React Native Text,使用通过 expo-font 加载的内置字体。普通 JavaScript 核心提供着色器源码,以及用于悬停和按压值的指数逼近步进,由 requestAnimationFrame 循环推进。网页预览通过 WebGL 运行相同的着色器主体。
适用场景
- 深色落地页或首屏上的主要行动号召按钮
- 付费或 AI 功能入口的高亮按钮
- 完全在着色器内绘制图标和柔和光照的参考
依赖
@shopify/react-native-skiaexpo-fontreact-native标签
按钮光标跟随深色光效辉光渐变图标液态玻璃按压反馈着色器拟物3D