Label
ComponentsAccessible form labels.
Live Functional Playground Interactive Hooks • useState
Interactive Preview
useState Active
Click element to toggle state
Motion Physics & Animation Showcase Framer Motion ✨
Motion Physics
✨
Hover to trigger spring elevation lift
Format:
Required Animation Library: framer-motion & lucide-react
Install this package in your project before importing the animated component.
npm i framer-motion lucide-react <label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">Email Address</label> <label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">Email Address</label> "use client";
import React, { useState } from "react";
interface LabelProps {
className?: string;
children?: React.ReactNode;
}
export default function Label({
className = "",
children,
}: LabelProps) {
const [isActive, setIsActive] = useState(false);
return (
<div
onClick={() => setIsActive(!isActive)}
className={`transition-all ${isActive ? "ring-2 ring-primary/30 rounded-xl" : ""} ${className}`}
>
<label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">Email Address</label>
</div>
);
} "use client";
import React from "react";
import { motion } from "framer-motion";
export default function AnimatedLabel() {
return (
<motion.div
initial={{ opacity: 0, scale: 0.96 }}
animate={{ opacity: 1, scale: 1 }}
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
transition={{ type: "spring", stiffness: 350, damping: 25 }}
className="cursor-pointer"
>
<label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">Email Address</label>
</motion.div>
);
}