Direction Aware Hover
- Source
- Aceternity UI ↗
- Author
- Aceternity UI
- Licence
- Aceternity UI licence (free component)
Loading…
The caption slides in from whichever side the pointer entered.
Code
"use client";
import { DirectionAwareHover } from "@/lab/aceternity/ui/direction-aware-hover";
import { Fit } from "./_fit";
export default function DirectionAwareHoverDemo() {
const imageUrl =
"https://images.unsplash.com/photo-1663765970236-f2acfde22237?q=80&w=1200&auto=format&fit=crop&ixlib=rb-4.0.3";
return (
<Fit width={460} height={460} max={1.4}>
<div className="h-full relative flex items-center justify-center">
<DirectionAwareHover imageUrl={imageUrl} className="h-96 w-96 md:h-96 md:w-96">
<p className="font-bold text-xl">In the mountains</p>
<p className="font-normal text-sm">$1299 / night</p>
</DirectionAwareHover>
</div>
</Fit>
);
}
Prompt
Build "Direction Aware Hover", a card animation. What it does: The caption slides in from whichever side the pointer entered. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library. It sits on a light background, in a square frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/direction-aware-hover (Aceternity UI, Aceternity UI licence (free component)).