Skillpedia
المواقع والواجهات (frontend)7.2k · #13446

liquid-metal-border

ما الذي تفعله

تُرشد هذه المهارة وكيلًا للذكاء الاصطناعي في إضافة حد معدني متحرك بـ WebGL حول عنصر في React باستخدام حزمة metal-fx. وهي موجهة للمطورين الذين يريدون تمييزًا راقيًا للعناصر المختارة أو النشطة.

متى تستخدمها

  • ✓عندما يجب أن يظهر زر أو بطاقة أو تبويب بحد معدني عند اختياره أو تنشيطه.
  • ✓عندما تحتاج حالة مميزة أو مدفوعة إلى حافة معدنية سائلة.
  • ✓عندما يحتاج حد معدني إلى ضبط أو إصلاح داخل مشروع React.

رابط المهارة

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/liquid-metal-border/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/liquid-metal-border/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أضف حدًا معدنيًا سائلًا إلى بطاقة التسعير المختارة في تطبيق React، مع حد عادي احتياطي.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يغلّف وكيلك عنصرًا تفاعليًا حقيقيًا واحدًا بمكون المعدن، ويربط حركته بحالة النشاط أو الاختيار. يبقى حد ثابت احتياطيًا، وتُوقف العناصر غير النشطة لتوفير الموارد.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Liquid Metal Border

Core Contract

  1. Use metal-fx in React 18 or newer.
  2. Wrap exactly one real host element such as a button, a, div, or article.
  3. Keep the host semantic and interactive. MetalFx is visual framing, not the control.
  4. Reserve the animated border for active, selected, focused, hovered, or primary surfaces. Do not put it around every control.
  5. Keep a static CSS border or focus outline as the fallback. WebGL decoration must never carry essential state by itself.
  6. Pause non-active instances and reduced-motion experiences.
  7. Test light and dark modes independently. Reflections intentionally render only in dark mode.

Inspect Before Editing

  • Confirm the project uses React and has react and react-dom version 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-fx version 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
آخر تحديث
1‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة