Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Vim Command Sequence Kbd for React

Colon, W, and Q in a row, the three presses for Vim's save-and-quit command, shown as separate caps.

Three caps read colon, W, and Q, with a small gap. They are a sequence, not a chord, because they are not in a group. The demo does not run the command.

Use a tight row for a typed command. For keys held together, use a group. If quit would discard work, confirm in an Alert Dialog. In React, Base UI does not run the command.

Preview

Preview width
:WQ

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Kbd anatomy: kbd, group

Usage

<div className="rounded-md border bg-background p-4">
  <div className="flex items-center gap-1">
    <Kbd>:</Kbd>
    <Kbd>W</Kbd>
    <Kbd>Q</Kbd>
  </div>
</div>

FAQ

What is Vim's command mode?

Typing a colon in normal mode opens a command line at the bottom of the screen. You type a command, like wq, and press Enter to run it, or Esc to cancel.

Why so little space between the keys?

The keys are typed as one word, so gap-1 keeps them together. A wider gap, or an arrow, would suggest separate steps with a pause between them.

Are Vim commands case-sensitive?

Yes: the command is :wq in lowercase, and :WQ fails. The caps show capital letters because that's what keyboards print; say lowercase in the text, or show the command in code next to the keys.

Which Vim commands are worth documenting?

:w to save, :q to quit, :wq to save and quit, :q! to quit without saving, and / to search. Those get most people in and out of Vim.

Why wq instead of write quit?

Vim commands have short forms so they're quick to type: w is short for write and q for quit. The full forms, like :write, work too.

Do screen readers read the sequence correctly?

They read colon, W, Q as separate characters, which matches what to type. Add the command in text, such as Type :wq and press Enter, so the Enter step isn't missed.

API Reference

Kbd

No extra props in this demo. The rest is on the Kbd page.