Background & Cursor

Import

To use the Background and Cursor components in your project, import them as follows:

import { Background } from "@purrfect-ui/components";
import { Cursor } from "@purrfect-ui/components";

Usage

These components combine to create an interactive background grid with a cursor effect that reacts to mouse movements. Here's an example of how to use them together:

Basic Usage


import React from "react";
import { Background } from "@purrfect-ui/components";
import { Cursor } from "@purrfect-ui/components";

const colors = ["#83ffff", "#fd80fb"];
const randomColor = colors[Math.floor(Math.random() * colors.length)];

export function BackgroundDemo() {
    return (
        <>
            <div
                className="fixed inset-0 flex-1 opacity-5 pointer-events-none mix-blend-multiply transition-opacity duration-300 ease-in-out group-hover:opacity-30"
            >
                <Background color="white" />
            </div>
            <div
                className="fixed inset-0 flex-1 pointer-events-none mix-blend-multiply hidden md:flex"
            >
                <Background
                    color={randomColor}
                    isMasked={true}
                    showCursor={true}
                />
            </div>
            <Cursor />
        </>
    );
}

export default BackgroundDemo;

Key Features

  • Dynamic Grid: Automatically adjusts the number of squares based on screen size, offering a responsive and adaptive background.

  • Customizable Appearance: Easily change the color, stroke, gap, and scaling of the grid, or apply a mask to create an interactive effect.

  • Interactive Cursor: The cursor dynamically moves and interacts with the background, enhancing the overall user experience.

  • Accessibility Friendly: Supports visual adjustments and custom styling for better usability.

  • Lightweight: Efficiently handles large grids with minimal performance impact, ensuring smooth interactions across devices.