shadcn.io is not affiliated with official shadcn/ui
Paste is the other half of copy. This React example shows Ctrl and V in a KbdGroup, which spaces the two caps evenly and marks them as one shortcut. Use it in upload areas that accept pasted images, in editors and in help text, and show ⌘V instead to Mac users.
Preview
Installation
FAQ
Why V for paste when C is copy and X is cut?
The letters were chosen for their place, not their names: Z, X, C and V sit together at the bottom left of the keyboard, next to the modifier. V is often said to look like the caret proofreaders use to mark an insertion.
Is it Ctrl V on Mac?
No, it's ⌘V on macOS and Ctrl V on Windows, Linux and ChromeOS. Show the one that matches the user's platform.
How do I handle pasted content myself?
Listen to the paste event and read event.clipboardData, for text with getData or for images and files with files. Call preventDefault only if you insert the content yourself. These are browser APIs and work the same in every framework.
Should pasted content be validated or transformed?
Often, yes: strip formatting from rich text pasted into a plain field, trim spaces from pasted codes, check the type and size of pasted files. Never insert pasted HTML into the page without sanitizing it.
Related
- Copy Shortcut KbdThe Ctrl C copy shortcut as a key group
- Save Shortcut KbdThe ⌘S save shortcut as a key group
- Complex Shortcut KbdA three-key Ctrl Shift P shortcut in one
- Command Palette Shortcut KbdThe ⌘K shortcut that opens a command
- Simple TextareaA plain textarea with a placeholder and
- Arrow Keys Cross Pattern KbdFour arrow keys in the inverted T of a