Realistic Button
harshkanjiya/realistic-buttonFreeComponent
A skeuomorphic realistic button with hover and active states.
Live preview
live · rendered by the registry
Rendered by harshkanjiya on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://harshkanjiya.com/r/realistic-button.jsonSource
1'use client';23import { useState, useEffect } from 'react';4import styles from './realistic-button.module.css';5import { useSound } from '@/hooks/use-sound';67type TextState = 'off' | 'drawing' | 'on';89export default function RealisticButton() {10 const [isActive, setIsActive] = useState(false);11 const [isPressed, setIsPressed] = useState(false);12 const [textState, setTextState] = useState<TextState>('off');1314 const playClick = useSound("/audio/ui-sounds/mech-key-press.mp3");1516 useEffect(() => {17 if (isActive) {18 setTextState('drawing');19 const timer = setTimeout(() => setTextState('on'), 900);20 return () => clearTimeout(timer);21 } else {22 setTextState('off');23 }24 }, [isActive]);2526 const onClick = () => {27 playClick();28 setIsPressed(true);29 setIsActive(false);30 setTimeout(() => setIsPressed(false), 200);31 }3233 return (34 <div className={`${styles.wrap} sm:scale-[0.6] scale-[0.5]`}>35 <button36 className={`${styles.button} ${isPressed ? styles.buttonPressed : ''} relative overflow-hidden w-[250px] h-[96px] bg-black z-20 border-transparent rounded-[24px]`}37 onMouseEnter={() => setIsActive(true)}38 onClick={onClick}39 onMouseLeave={() => { setIsActive(false); setIsPressed(false); }}40 onMouseDown={() => setIsPressed(true)}41 onMouseUp={() => setIsPressed(false)}42 onTouchStart={() => setIsPressed(true)}43 onTouchEnd={() => setIsPressed(false)}44 style={{45 boxShadow: isActive || isPressed46 ? 'inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 0 -6px 1px -4px #ff7300, inset 0 -15px 6px -8px #cc5500,'47 : 'inset 0 1px 1px rgb(255 255 255 / 40%), inset 0 -6px 1px -4px #ff7300, inset 0 -15px 6px -8px #ff6600',48 transform: isPressed ? 'scale(0.94)' : 'scale(1)',49 transition: isPressed50 ? 'transform 0.07s ease, box-shadow 0.07s ease'51 : 'transform 0.2s ease, box-shadow 0.3s ease',52 }}53 >54 <div className={`${styles.corner} absolute opacity-10 transition-all duration-400`}></div>5556 <div57// … truncated
Files it writes
More from harshkanjiya
All 6 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Hello Worldhello-world | harshkanjiya | Components | Free | no deps · 2 files | |
| Pintch Switchpintch-switch | harshkanjiya | Components | Free | no deps · 4 files | |
| Shutter CTAshutter-cta | harshkanjiya | Components | Free | no deps · 2 files | |
| Toggletoggle | harshkanjiya | Components | Free | no deps · 4 files |
