DirectionHover

The DirectionHover component is a way to display images with a hover effect that shows the direction of the entering mouse.

Importation

Import the component from pol-ui to use the conveyor element:

import { DirectionHover } from "pol-ui";

Default DirectionHover

Default

import { DirectionHover } from "pol-ui";
 
import React from "react";
 
const DirectionHoverComponent = () => {
  return (
    <DirectionHover imageUrl="https://source.unsplash.com/random">
      <div className="flex flex-col items-center justify-center ">
        <h2 className="text-white">Hover me</h2>
      </div>
    </DirectionHover>
  );
};
export default DirectionHoverComponent;

Props

Prop nameTypeDefaultDescription
imageUrlstringThe url of the image to display
childrenReact.ReactNode | stringThe content to display on hover
childrenClassNamestringThe class name to apply to the children element
imageClassNamestringThe class name to apply to the image element
roundedRoundedSizesThe rounded size to apply to the image
altstringThe alt text to apply to the image
classNamestringThe class name to apply to the root element
themeDirectionHoverThemeThe theme to apply to the root element
speednumberThe speed of the hover effect

Examples

Line example

Line example

import { DirectionHover } from "pol-ui";
 
import React from "react";
 
const DirectionHoverComponent = () => {
  return (
    <div className="flex gap-2">
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
    </div>
  );
};
export default DirectionHoverComponent;

Grid example

Another interesting use case is to display a grid of images with the hover effect, the images will create a nice effect when the mouse enters the grid.

Grid example

import { DirectionHover } from "pol-ui";
 
import React from "react";
 
const DirectionHoverComponent = () => {
  return (
    <div className="grid grid-cols-3 grid-rows-3 gap-2">
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
      <DirectionHover imageUrl="https://source.unsplash.com/random">
        <div className="flex flex-col items-center justify-center ">
          <h2 className="text-white">Hover me</h2>
        </div>
      </DirectionHover>
    </div>
  );
};
export default DirectionHoverComponent;

Theme

To learn more about how to customize the appearance of components, please see the Theme docs.

interface DirectionHoverTheme {
  base: string;
  overlay: string;
  background: {
    wrapper: string;
    image: string;
  };
 
  children: string;
 
  rounded: RoundedSizesElastic;
}

Since February 16, 2024

Proudly Open Source
  • Npm

  • Github

  • Creator

  • Made with love and Pol-ui by Pol Gubau Amores