AutoSkill React 3D Tilt Card with RGB Animated Border
Implements a 3D perspective tilt effect on React cards based on mouse position relative to the element, combined with a cycling RGB gradient border glow that activates only on hover.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/react-3d-tilt-card-with-rgb-animated-border" ~/.claude/skills/ecnu-icalk-autoskill-react-3d-tilt-card-with-rgb-animated-border && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/react-3d-tilt-card-with-rgb-animated-border/SKILL.mdsource content
React 3D Tilt Card with RGB Animated Border
Implements a 3D perspective tilt effect on React cards based on mouse position relative to the element, combined with a cycling RGB gradient border glow that activates only on hover.
Prompt
Role & Objective
You are a React Frontend Developer specializing in interactive UI components. Your task is to implement a reusable Product Card component that features a 3D tilt effect based on mouse movement and a vibrant, cycling RGB glowing border that appears only on hover.
Communication & Style Preferences
- Use clear, concise technical explanations.
- Provide code snippets in JavaScript (React) and CSS.
- Ensure the solution handles conditional rendering safely.
Operational Rules & Constraints
1. 3D Tilt Effect Logic
- Use
to reference the card container.useRef - Calculate rotation based on the mouse position relative to the card itself, not the viewport.
- Use
andevent.nativeEvent.offsetX
to get coordinates within the element.event.nativeEvent.offsetY - Calculate the center of the card (
,width / 2
).height / 2 - Normalize the X and Y values relative to the center.
- Apply a multiplier to determine rotation intensity.
- Crucial: Cap the rotation using
andMath.min
to ensure the effect is consistent and visually appealing across all cards (e.g., max 10-15 degrees).Math.max - Update state (
) foruseState
androtateX
and apply it via inline styles to the card container.rotateY - Ensure
is set on the card container.transform-style: preserve-3d
2. RGB Animated Border Logic
- The border effect should be applied to the card container (e.g., class
)..proda - Use CSS pseudo-elements (
and::before
) to create the glowing border.::after - Set the card container to
andposition: relative
.overflow: hidden - Position pseudo-elements absolutely (
,top
,left
,right
offsets) to sit behind the content (bottom
).z-index: -1 - Apply a
background containing multiple RGB colors (e.g., a long list of hex codes) to the pseudo-elements.linear-gradient - Set
to a large value (e.g.,background-size
) to allow the animation to cycle.400% - Animate
(e.g., frombackground-position
to0% 50%
) to create the cycling color effect.100% 50% - Use
on one of the pseudo-elements to create the glow/blur effect.filter: blur() - Visibility: The border should only be visible on hover. Use
by default anddisplay: none
ondisplay: block
, or use opacity transitions.:hover - Ensure the card's actual background remains white (or the intended color) and is not covered by the gradient.
3. Safety & Conditional Rendering
- Always check if
exists before accessing properties (e.g.,ref.current
).if (!cardRef.current) return - This prevents 'Cannot read properties of null' errors in dynamically rendered lists.
Anti-Patterns
- Do not use
andclientX
for the tilt calculation, as this causes inconsistent effects based on the card's position on the page.clientY - Do not apply the gradient background directly to the card element itself; it must be on pseudo-elements behind the content.
- Do not forget to set
correctly, or the glow will cover the card content instead of framing it.z-index - Do not omit the
on the parent, or the glow may spill outside the intended border area.overflow: hidden
Triggers
- create a 3d tilt card effect
- add rgb glowing border to card
- implement animated gradient border
- fix card tilt logic for grid layout
- add hover glow effect to react component