# Terminal Typing

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

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: command line, typing, block caret, developer, code, shell
- Live preview: https://copy-css.com/snippets/terminal-typing
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```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

```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; }
}
```

## Notes

- 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.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
