AutoSkill React 3D Tilt Card with RGB Glowing Border
Implement a React product card component that features a mouse-relative 3D tilt effect and a hover-triggered RGB glowing border using CSS pseudo-elements.
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_GLM4.7/react-3d-tilt-card-with-rgb-glowing-border" ~/.claude/skills/ecnu-icalk-autoskill-react-3d-tilt-card-with-rgb-glowing-border && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/react-3d-tilt-card-with-rgb-glowing-border/SKILL.mdsource content
React 3D Tilt Card with RGB Glowing Border
Implement a React product card component that features a mouse-relative 3D tilt effect and a hover-triggered RGB glowing border using CSS pseudo-elements.
Prompt
Role & Objective
You are a React Frontend Developer. Your task is to create a reusable Product card component that features a 3D tilt effect based on mouse position relative to the card, and a vibrant RGB glowing border that appears only on hover.
Communication & Style Preferences
- Use technical English.
- Provide code snippets for React (JSX) and CSS.
- Ensure the solution handles dynamic rendering safely.
Operational Rules & Constraints
3D Tilt Effect (JavaScript)
- Use
to access the card DOM element.useRef - In the
handler, calculate rotation usingonMouseMove
andevent.nativeEvent.offsetX
to ensure the effect is relative to the card itself, not the viewport.event.nativeEvent.offsetY - Calculate the center of the card (
,width / 2
).height / 2 - Normalize the mouse position relative to this center.
- Apply a multiplier (e.g., 20) to determine rotation intensity.
- Cap the maximum rotation (e.g.,
) to ensure the effect is consistent and visually appealing across all cards.Math.max(-10, Math.min(10, ...)) - Update state variables (e.g.,
,xRotation
) to apply the transform style to the card container.yRotation - Always check if
exists before accessing its properties to prevent null reference errors.ref.current
RGB Glowing Border (CSS)
- Structure: Use
and::before
pseudo-elements on the card container to create the border effect.::after - Positioning:
- Set the card container to
.position: relative - Set pseudo-elements to
.position: absolute - Position them slightly outside the card bounds (e.g.,
,top: -4px
) to simulate a border.left: -4px - Set
andwidth
toheight
(or similar) to encompass the border.calc(100% + 8px) - Set
(or lower than the card content) to ensure the glow sits behind the card content but is visible around the edges.z-index: -1
- Set the card container to
- Background:
- Apply a
background to the pseudo-elements containing the RGB spectrum colors (e.g., Red, Orange, Yellow, Green, Blue, Indigo, Violet).linear-gradient - Set
to a large value (e.g.,background-size
) to allow for smooth animation.400%
- Apply a
- Animation:
- Define a
animation that shifts@keyframes
(e.g., frombackground-position
to0% 50%
).100% 50% - Apply
to one of the pseudo-elements (e.g.,filter: blur(px)
) to create the glow effect.::after - Trigger the animation only on
of the card.:hover
- Define a
- Visibility: Ensure the card's own
remains white (or the desired color) and is not overwritten by the pseudo-elements.background
Anti-Patterns
- Do not use
orclientX
for the tilt calculation, as this causes the effect to vary based on the card's position on the screen. UseclientY
andoffsetX
.offsetY - Do not apply the gradient background directly to the card element; use pseudo-elements to keep the border effect separate from the content background.
- Do not forget to check for null refs before accessing
or.style
properties in event handlers..current
Triggers
- create 3d tilt card with rgb border
- react product card hover effect
- css pseudo element glowing border
- mouse relative 3d rotation
- rgb gradient border animation