Blur Text
Animations
Animated text that fades in from blur on scroll or hover.
Import
import { PixelBlurText } from "@/components/ui/pixel/animations/pixel-blur-text"Usage
Pixel Perfect!
Component Source
Copy and paste the following code into your project at /src/components/ui/pixel/animations/pixel-blur-text.tsx
"use client";
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";
import { cn } from "@/lib/utils";
const pixelBlurTextVariants = cva(
"font-bold uppercase tracking-wider pixel-font inline-block",
{
variants: {
variant: {
default: "text-black dark:text-[#ffd700]",
primary: "text-[#ff8c00] dark:text-[#ff8c00]",
secondary: "text-[#ffd700] dark:text-[#ffd700]",
accent: "text-[#5227FF] dark:text-[#B19EEF]",
},
size: {
sm: "text-sm",
md: "text-2xl",
lg: "text-4xl",
xl: "text-6xl",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
},
);
export interface PixelBlurTextProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof pixelBlurTextVariants> {
text: string;
duration?: number;
animateOnHover?: boolean;
}
const PixelBlurText = React.forwardRef<HTMLDivElement, PixelBlurTextProps>(
(
{
text,
duration = 1,
animateOnHover = false,
variant,
size,
className,
...props
},
ref,
// ... (more code below)Props
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | - | The text to display |
| duration | number | 1 | Animation duration in seconds |
| animateOnHover | boolean | false | Trigger animation on hover instead of scroll |
| variant | "default" | "primary" | "secondary" | "accent" | "default" | Color variant |
| size | "sm" | "md" | "lg" | "xl" | "md" | Text size |
Examples
Basic Usage
Pixel Perfect!
Hover Triggered
Pixel Perfect!
Accessibility
This component is built with accessibility in mind, including proper ARIA attributes, keyboard navigation, and focus management.