React Parallax Tilt logo

React Parallax Tilt

Create interactive 3D tilt effects with this lightweight, zero-dependency React component.

npm install react-parallax-tilt
1.0K37.1K/weekv1.7.31470.21 KBMIT0 issues
Last updated: 2025-11-24
Star history chart for mkosir/react-parallax-tilt

TL;DR

A specialized component that applies highly performant, Apple TV-style 3D tilt effects to any React element.

It features zero dependencies, supports gyroscope input for mobile devices, and includes built-in glare and scaling effects.

Why React Parallax Tilt?

In a web landscape dominated by flat design, depth can be a powerful differentiator. react-parallax-tilt is a "one-trick pony" in the best possible way: it does one specific visual effect—the 3D tilt interaction popularized by tvOS—and does it exceptionally well. It abstracts away the complex math of calculating perspective, rotation matrices, and mouse coordinate tracking into a single wrapper component.

  • Zero Dependencies: It creates complex 3D transforms without dragging in heavy math libraries or physics engines. The bundle impact is negligible (~3kB).
  • Feature Rich: Beyond basic tilting, it includes built-in support for glare effects (simulating light reflection), scaling on hover, and even flipping axes.
  • Universal Input: It works seamlessly with mouse movements on desktop and gyroscope/accelerometer data on mobile devices, creating a physical connection to the UI.
  • Performance Optimized: Uses CSS transform: preserve-3d and requestAnimationFrame to ensure animations run at 60fps (or higher) without layout thrashing.

Code Snippet

Using the library is as simple as wrapping your existing component. The example below enables a tilt effect with a "glare" reflection and a slight zoom on hover.

import React from 'react';
import Tilt from 'react-parallax-tilt';

const ProductCard = () => {
  return (
    <Tilt
      tiltMaxAngleX={25}
      tiltMaxAngleY={25}
      perspective={1000}
      scale={1.1}
      transitionSpeed={1500}
      glareEnable={true}
      glareMaxOpacity={0.45}
      glarePosition="all"
    >
      <div className="card">
        <h1>3D Effect</h1>
        <p>Hover over me (or tilt your phone)!</p>
      </div>
    </Tilt>
  );
};

In this snippet, the Tilt component handles all the event listeners and CSS transforms. The glareEnable prop adds an overlay that simulates a light source moving across the surface.

Pros and Cons

No library is perfect; understanding the trade-offs is key to selecting the right tool.

Pros

  • High Visual ROI: You get a premium, "expensive-looking" interaction for almost zero development effort.
  • TypeScript Support: Written in TypeScript, providing excellent autocomplete for its many configuration props.
  • Cross-Platform: Handles both mouse (hover) and touch/gyroscope events gracefully, with fallback modes.

Cons

  • Accessibility Risks: Strong perspective shifts can trigger vestibular disorders (motion sickness) in some users. It should ideally be disabled if prefers-reduced-motion is detected.
  • Gyroscope Complexity: On iOS 13+, accessing device orientation requires explicit user permission (a button click), which the library doesn't handle automatically for you.
  • Style Conflicts: Because it relies heavily on transform and overflow, it can sometimes conflict with complex existing CSS layouts or z-index contexts.

Comparison with Other Animation Libraries

The table below outlines the positioning differences between React Parallax Tilt and generic animation libraries:

LibraryDesign PhilosophyBest ForPain Points
React Parallax TiltSpecialized Tool
Do one thing perfectly: 3D tilt interactions.
Micro-interactions
Product cards, hero images, and portfolio showcases.
Scope
It only does tilt. You need other libs for general animation.
Framer MotionGeneral Purpose
Complete motion system for React.
Orchestration
Complex page transitions and state-driven animation.
Complexity
Recreating the "glare" and tilt math manually is tedious.
React SpringPhysics Based
Simulating real-world physics forces.
Fluidity
UI that needs to feel heavy or springy.
Math
You have to calculate the rotation values based on mouse position yourself.

Verdict: When to Adopt

Adopt React Parallax Tilt when you need to add a specific "wow" factor to a landing page, product showcase, or creative portfolio. It is the most efficient way to implement the "hover tilt" effect. However, use it sparingly—overusing 3D effects can make an interface feel chaotic and overwhelm users. For general UI animation (modals, lists), stick to standard libraries like Framer Motion or AutoAnimate.