Kinetic UI
Back to Introduction
Mouse Interactions

Directional Hover

A smart card wrapper that detects mouse entry direction and animates an overlay with 5 unique effects.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add directional-hover

The DirectionalHover component tracks mouse events and calculates the angle of entry relative to the center of the bounding box. It then uses Framer Motion's AnimatePresence with custom variants to animate an overlay from the exact edge your cursor crossed — with 5 distinct animation effects.

Live Preview

Directional Hover
📊DashboardAnalytics
⚡WorkflowAutomation
🎨DesignSystem
🛡️SecurityShield
🧠AI EngineInference
☁️DeployCloud

Slide:Classic directional slide — the overlay enters from whichever edge your cursor crosses.

Installation

npx kinetic-ui-cli@latest add directional-hover

Props

Effects

| Effect | Animation | Feel | |---|---|---| | slide | Full slide from entry edge | Classic, snappy | | fade | Opacity crossfade | Subtle, elegant | | scale | Expand from entry edge | Curtain reveal | | flip | 3D perspective rotation | Dramatic, playful | | blur | Slide with gaussian blur dissolve | Dreamy, cinematic |

How it Works

The component calculates the angle between the cursor and the card center using Math.atan2. It maps the result to one of four quadrants (top/right/bottom/left). That direction is passed as a custom prop to Framer Motion variants, which adapt the initial/exit animation accordingly. The effect prop selects which set of variants to use — from simple opacity fades to perspective-aware 3D flips.

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

import { DirectionalHover } from "@/components/creative/directional-hover";

2. Implementation Example

Render the component and customize its behavior by passing props:

import { DirectionalHover } from "@/components/creative/directional-hover";

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <DirectionalHover
        overlayContent{/* value */}
        overlayClassName="example"
        effect{/* value */}
      >
        <div>Content goes here</div>
      </DirectionalHover>
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.