CSS Terminal Typing

A dark terminal window that types a command with a block caret, then prints the output line.

  • command line
  • typing
  • block caret
  • developer
  • code
  • shell
HTML
<div class="term-typing">
  <p class="term-typing-line"><span class="term-typing-cmd">npm i copycss</span></p>
  <p class="term-typing-out">added 1 package in 0.4s</p>
</div>
CSS
.term-typing {
  box-sizing: border-box;
  width: 250px;
  max-width: 100%;
  padding: 16px 18px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font: 500 14px/1.7 ui-monospace, Menlo, monospace;
  box-shadow: 0 12px 30px #0f172a40;
}

.term-typing p {
  margin: 0;
}

.term-typing-line::before {
  content: "$ ";
  color: #4ade80;
}

/* Width in ch = number of characters in the command */
.term-typing-cmd {
  display: inline-block;
  width: 13ch;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  animation: term-typing-type 1.3s 0.4s steps(13) both;
}

.term-typing-line::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  vertical-align: -0.2em;
  background: #4ade80;
  animation: term-typing-blink 1s step-end infinite;
}

.term-typing-out {
  color: #94a3b8;
  animation: term-typing-show 0.2s 2s both;
}

@keyframes term-typing-type {
  from { width: 0; }
}

@keyframes term-typing-blink {
  50% { opacity: 0; }
}

@keyframes term-typing-show {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .term-typing-cmd,
  .term-typing-out,
  .term-typing-line::after { animation: none; }
}

About this CSS Terminal Typing

This CSS Terminal Typing is 63 lines of pure CSS (1.2 KB) with no JavaScript and no dependencies. It uses keyframe animations, box shadows and reduced-motion support. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #0f172a
  • #e2e8f0
  • #0f172a40
  • #4ade80
  • #94a3b8

How to use this terminal typing

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .term-typing class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback