Components
npx shadcn@latest add https://21st.dev/r/ShadcnStudio/buttonsLoading preview...
'use client'
import { useState } from 'react'
import { CheckIcon, CopyIcon } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/utils'
const ButtonCopyStateDemo = () => {
const [copied, setCopied] = useState<boolean>(false)
const handleCopy = async () => {
try {
await navigator.clipboard.writeText('Thank you for using Shadcn Studio!')
setCopied(true)
setTimeout(() => setCopied(false), 1500)
} catch (err) {
console.error('Failed to copy text: ', err)
}
}
return (
<Button variant='outline' className='btn relative disabled:opacity-100' onClick={handleCopy} disabled={copied}>
<span className={cn('transition-all', copied ? 'scale-100 opacity-100' : 'scale-0 opacity-0')}>
<CheckIcon className='stroke-green-600 dark:stroke-green-400 ' size={17} />
</span>
<span className={cn('absolute left-4 transition-all', copied ? 'scale-0 opacity-0' : 'scale-100 opacity-100')}>
<CopyIcon size={17} />
</span>
{copied ? 'Copied!' : 'Copy'}
</Button>
)
}
export default ButtonCopyStateDemo
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...