shadcn.io is not affiliated with official shadcn/ui
Kbd examples · With Icons
Delete with Icon Kbd for React
A Del key with a delete icon before its label.
A delete key reads faster with its shape next to the word. This React example puts Lucide's Delete icon, hidden from screen readers, before the label Del inside one Kbd cap. The Kbd lines up the icon and text with a small gap and sizes the icon to the text.
Preview
Installation
FAQ
Does this icon mean Delete or Backspace?
Lucide's Delete icon is a key shape pointing back with an X in it, like the ⌫ symbol, which usually means Backspace. Here it's paired with Del, so the label decides; for Backspace, change the label.
Should I document Delete and Backspace separately?
Yes, if both do something. Backspace removes the character before the cursor and Delete the one after it. On Mac, the key labeled delete is Backspace, and Fn delete is forward delete.
Should the delete key look destructive?
A Kbd is a label for a key, so keep it neutral. Put the warning on the action: a destructive Button or menu item next to the shortcut.
How do I make the delete key accessible?
The icon is hidden with aria-hidden, and the text Del is what screen readers read. Writing Delete in full, or adding it as visually hidden text, avoids the abbreviation.
Should the Delete key ask for confirmation?
For things that can't be undone, yes: open an Alert Dialog. For things that can, delete right away and offer undo; it's faster and just as safe.
Related
- Enter with Icon KbdAn Enter key with a return arrow icon
- Unicode Symbols KbdEnter, Delete and Tab keys with a Unicode
- Special Keys KbdThe Esc, Tab and Enter keys in a row
- Button with Text (Destructive)Delete, in the danger color
- Arrow Keys with Icons KbdUp, down, left and right arrow keys drawn
- Command with Icon KbdA Command K shortcut with the Command key