Introdcution
Create Stunning Cursor Animations with Ease. Cursify is a powerful library designed to elevate your React and Next.js projects. With an extensive collection of cursor animations, pre-built components, code blocks, and design templates, Cursify empowers you to craft visually stunning landing pages and marketing interfaces effortlessly.
Installation
You must install tailwindcss
. As most of our components use framer-motion
install it too.
1npm install framer-motion clsx tailwind-merge
Must Add it in the utils.ts
:
1import { type ClassValue, clsx } from 'clsx';2import { twMerge } from 'tailwind-merge';34export function cn(...inputs: ClassValue[]) {5return twMerge(clsx(inputs));6}
we're using this hooks for most of our components:
1'use client';2import { type RefObject, useLayoutEffect, useRef, useState } from 'react';34interface MouseState {5x: number | null;6y: number | null;7elementX: number | null;8elementY: number | null;9elementPositionX: number | null;10elementPositionY: number | null;11}1213export function useMouse(): [MouseState, RefObject<HTMLDivElement>] {14const [state, setState] = useState<MouseState>({15x: null,16y: null,17elementX: null,18elementY: null,19elementPositionX: null,20elementPositionY: null,21});2223const ref = useRef<HTMLDivElement | null>(null);2425useLayoutEffect(() => {26const handleMouseMove = (event: MouseEvent) => {27const newState: Partial<MouseState> = {28x: event.pageX,29y: event.pageY,30};3132if (ref.current instanceof Element) {33const { left, top } = ref.current.getBoundingClientRect();34const elementPositionX = left + window.scrollX;35const elementPositionY = top + window.scrollY;36const elementX = event.pageX - elementPositionX;37const elementY = event.pageY - elementPositionY;3839newState.elementX = elementX;40newState.elementY = elementY;41newState.elementPositionX = elementPositionX;42newState.elementPositionY = elementPositionY;43}4445setState((s) => ({46...s,47...newState,48}));49};5051document.addEventListener('mousemove', handleMouseMove);5253return () => {54document.removeEventListener('mousemove', handleMouseMove);55};56}, []);5758return [state, ref];59}
Story
I was exploring Ui-Layouts components and noticed they didn’t have any mouse events or cursor animations. So, I thought, why not create a Cursor Components Library? I went ahead and built it, but the UI and design process were all manual. I wasn’t using developer-friendly tools like MDX. That’s when Naymur reached out to me and said he could completely change the structure—how components are added, how users view and copy them—just like he did in Ui-Layouts. Now, you’re checking out the new version of Cursify, which has become an exciting project under Ui-Layouts.
You can follow me and Naymur to see what we’ve been working on.