A JavaScript class that dynamically updates a CSS box-shadow based on mouse cursor position to create a direction-aware lighting effect.

Direction-Aware CSS Box Shadow

Direction-Aware CSS Box Shadow provides a reusable JavaScript class (DirectionAwareShadow) that calculates the mouse’s offsetX and offsetY relative to an element’s center. It then dynamically updates the element’s inline box-shadow property to cast a shadow in the opposite (or same) direction of the cursor. The class is highly configurable, allowing developers to easily adjust blur, spread, color, and offset intensity.

Technologies:
HTML CSS/SCSS JavaScript/Babel
Difficulty: Intermediate
Browser Support (as of Jun 2026):
Chrome Chrome 4+ Edge Edge 12+ Firefox Firefox 4+ Safari Safari 3.1+
Features:
Direction Aware Dynamic Shadow Reusable Class
Code by: Mert Cukuren Mert Cukuren
License: MIT

See the Pen Direction-Aware CSS Box Shadow.

Grid of portraits that flip in 3D like cubes based on the direction the mouse enters

Direction Aware 3D Cube Gallery

This is a Direction Aware 3D Cube Gallery. It tracks the exact angle at which a cursor enters or leaves an image tile, applying a responsive 3D cube rotation that follows the mouse’s trajectory. Its function is to provide highly contextual, physical feedback during interaction, making a flat image grid feel like an array of tangible, rotatable blocks.

Technologies:
Haml PostCSS Babel
Difficulty: Advanced
Browser Support (as of May 2026):
Chrome Chrome 60+ Edge Edge 79+ Firefox Firefox 55+ Safari Safari 11+
Features:
Direction Aware Hover 3D Transforms CSS Custom Properties Minimal DOM
Code by: Noel Delgado Noel Delgado
License: MIT
Grid of dark cards; the hovered card has a subtle glowing white border that follows the mouse cursor, created by CSS radial gradients

Stripe-Inspired Cards Hover Effect

This Stripe-Inspired Cards Hover Effect replicates the sophisticated “flashlight” border interaction seen on modern SaaS websites. Instead of a simple color change, a soft radial gradient follows the user’s mouse cursor across a grid of cards. This creates a cohesive, lighting-aware interface where elements seem to illuminate as you interact with them.

Technologies:
HTML SCSS JavaScript
Difficulty: Intermediate
Browser Support (as of Jan 2026):
Chrome Chrome 49+ Edge Edge 15+ Firefox Firefox 31+ Safari Safari 9.1+
Features:
Mouse Tracking CSS Variables Radial Gradient Mask Border Reveal
License: MIT
Direction-Aware SVG Cursor

Direction-Aware SVG Cursor

This custom SVG cursor rotates dynamically based on the mouse’s velocity and direction, achieved by calculating the angle between the previous and current coordinates using JavaScript’s Math.atan2 and applying the rotation via CSS transform.

See the Pen Direction-Aware SVG Cursor.