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.
Interaction Type
Click (or activate with keyboard) to copy the command. The field morphs width via grid-template-columns, blurs between command and success text, then resets after a short delay. Respects reduced motion.
Props
Options you can pass to customize this component.
value*Command or string written to the clipboard.
promptLeading prompt glyph (default: "$").
copiedLabelSuccess label after copy (default: "Copied to clipboard").
copyLabelAccessible label while idle (default: "Copy to clipboard").
resetDelayMilliseconds the success state stays visible (default: 2000).
onCopyCallback after a successful clipboard write.
hideIconHide the trailing copy/check icon.
disabledDisable interaction.
classNameAdditional CSS classes.
Installation
How to use
import { ClipboardField } from "@/components/ui/clipboard-field"
export function Demo() {
return (
<ClipboardField
value="npx shadcn@latest add @nexvyn/badge"
onCopy={() => console.log("copied")}
/>
)
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.