A copy-to-clipboard field that shows a monospace value in a read-only input with an icon or button trigger, animating a checkmark on copy.
Dependencies
Interaction Type
Click or press Enter on the copy button to copy the value with tactile audio feedback. The icon morphs into a checkmark and the result is announced to screen readers. Falls back to a legacy copy when the Clipboard API is unavailable.
Props
Options you can pass to customize this component.
valueThe value to display and copy to clipboard.
labelOptional label displayed above the value.
onCopyCalled after the value is copied.
variantIcon-only with tooltip, or a labeled button. Defaults to "icon".
alignPosition of the copy action relative to the value. Defaults to "right".
disabledDisables copying.
copyLabelAccessible label and tooltip for the icon trigger. Defaults to "Copy to clipboard".
copiedLabelText shown and announced after a successful copy. Defaults to "Copied".
failedLabelText announced when copying fails and the value is selected instead.
buttonTextTrigger text for the button variant. Defaults to "Copy".
resetDelayMilliseconds before the copied state resets. Defaults to 2000.
Installation
How to use
import { InputCopy } from "@/components/ui/input-copy"
export function Demo() {
return <InputCopy label="API Key" value="sk-proj-a1b2c3d4e5f6" variant="button" />
}Source Code
Click the code icon in the top-right corner to view the source code.
License & Usage
// No code loaded.