Clipboard Field
nexvyn/clipboard-fieldFreeComponent
A one-click install/copy field that morphs between the command and a success label using CSS grid fr tracks — JS only copies and toggles state.
Live preview
live · rendered by the registry
Rendered by nexvyn on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.nexvyn.dev/r/clipboard-field.jsonSource
1'use client'23import {4 forwardRef,5 useCallback,6 useEffect,7 useRef,8 useState,9 type ButtonHTMLAttributes,10} from 'react'11import { cn } from '@/lib/utils'12import { playHoverSound, playClickSound } from '@/lib/sound'1314const KEYFRAME_STYLE_ID = '__clipboard_field_kf__'1516function ensureKeyframes() {17 if (typeof document === 'undefined') return18 if (document.getElementById(KEYFRAME_STYLE_ID)) return19 const style = document.createElement('style')20 style.id = KEYFRAME_STYLE_ID21 style.textContent = `22 @keyframes cf-fade-out {23 from { opacity: 1; transform: scale(1); }24 to { opacity: 0; transform: scale(0.97); }25 }26 @keyframes cf-fade-in {27 from { opacity: 0; transform: scale(0.97); }28 to { opacity: 1; transform: scale(1); }29 }30 @keyframes cf-icon-exit {31 from { opacity: 1; transform: scale(1) rotate(0deg); }32 to { opacity: 0; transform: scale(0.7) rotate(-8deg); }33 }34 @keyframes cf-icon-enter {35 from { opacity: 0; transform: scale(0.7) rotate(8deg); }36 to { opacity: 1; transform: scale(1) rotate(0deg); }37 }38 `39 document.head.appendChild(style)40}4142export interface ClipboardFieldProps extends Omit<43 ButtonHTMLAttributes<HTMLButtonElement>,44 'children' | 'onCopy' | 'value'45> {46 value: string47 prompt?: string48 copiedLabel?: string49 copyLabel?: string50 resetDelay?: number51 onCopy?: () => void52 hideIcon?: boolean53}5455function CopyIcon({ className }: { className?: string }) {56 return (57 <svg58 width={14}59 height={14}60 viewBox="0 0 24 24"61 fill="none"62 stroke="currentColor"63 strokeWidth={1.75}64 strokeLinecap="round"65 strokeLinejoin="round"66 aria-hidden="true"67 className={className}68 >69 <rect x="9" y="9" width="12" height="12" rx="2" />70 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />71 </svg>72 )73}7475function CheckIcon({ className }: { className?: string }) {76 return (77 <svg78 width={14}79 height={14}80 viewBox="0 0 24 24"81 fill="none"82 stroke="currentColor"83 strokeWidth={2}84 strokeLinecap="round"85 strokeLinejoin="round"86 aria-hidden="true"87 className={className}88 >89 <path d="M20 6 9 17l-5-5" />90 </svg>91 )92}9394export const ClipboardField = forwardRef<HTMLButtonElement, ClipboardFieldProps>(95 (96 {97 value,98 prompt = '$',99 copiedLabel = 'Copied to clipboard',100 copyLabel = 'Copy to clipboard',101// … truncated
Files it writes
More from nexvyn
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | nexvyn | Components | Free | 1 dep | |
| Action Buttonaction-button | nexvyn | Components | Free | 3 deps · 4 files | |
| Adaptive Actionsadaptive-actions | nexvyn | Components | Free | 1 dep | |
| AI Inputai-input | nexvyn | Components | Free | 1 dep · 2 files | |
| Badgebadge | nexvyn | Components | Free | 2 deps · 2 files | |
| Bars Themebars-theme | nexvyn | Components | Free | 1 dep · 3 files | |
| Bounce Sidebarbounce-sidebar | nexvyn | Components | Free | 1 dep · 2 files | |
| Breadcrumbsbreadcrumbs | nexvyn | Components | Free | 1 dep · 2 files |
