Shutter CTA
harshkanjiya/shutter-ctaFreeComponent
A slide-to-action button with animated dot pulses.
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/shutter-cta.jsonSource
1"use client"23import Link from "next/link"4import { useRef, useState } from "react"5import { useRouter } from "next/navigation"67type Props = {8 baseDelay?: number; // starting time offset9};1011export function ArrowBlock({ baseDelay = 0 }: Props) {12 const pattern = [13 [1, 1, 0, 0],14 [0, 1, 1, 0],15 [0, 0, 1, 1],16 [0, 1, 1, 0],17 [1, 1, 0, 0],18 ];1920 return (21 <div className="grid gap-px grid-cols-4">22 {pattern.flatMap((row, r) =>23 row.map((cell, c) => {24 if (!cell) {25 return (26 <div27 key={`${r}-${c}`}28 className="h-[4px] w-[4px]"29 />30 );31 }32 const delay = baseDelay + (c * 120 + r * 60);33 return (34 <div35 key={`${r}-${c}`}36 className="h-[4px] w-[4px] bg-white rounded-full"37 style={{38 animation: `dotPulse 1.5s ease-in-out infinite`,39 animationDelay: `${delay}ms`,40 }}41 />42 );43 })44 )}45 <style jsx>{`46 @keyframes dotPulse {47 0%, 100% { opacity: 0.2; }48 50% { opacity: 1; }49 }50 `}</style>51 </div>52 );53}5455const arrows = [56 { delay: 0 },57 { delay: 200 },58 { delay: 400 },59 { delay: 600 },60 { delay: 800 },61];6263const INITIAL_W = 4264const SLIDE_THRESHOLD = 0.6 // 60% of max drag triggers navigation6566export function ShutterCta() {67 const router = useRouter()68 const buttonRef = useRef<HTMLButtonElement>(null)69 const touchStartX = useRef(0)70 const [dragWidth, setDragWidth] = useState<number | null>(null)71 const isDragging = useRef(false)7273 const handleTouchStart = (e: React.TouchEvent) => {74 touchStartX.current = e.touches[0].clientX75 isDragging.current = true76 setDragWidth(INITIAL_W)77 }7879 const handleTouchMove = (e: React.TouchEvent) => {80 if (!isDragging.current || !buttonRef.current) return81 const btnW = buttonRef.current.offsetWidth82// … 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 | |
| Realistic Buttonrealistic-button | harshkanjiya | Components | Free | no deps · 4 files | |
| Toggletoggle | harshkanjiya | Components | Free | no deps · 4 files |
