# Command line input

> A green phosphor console: type commands, bring back earlier ones with the arrow keys and complete them with Tab.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-in-terminal
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A small terminal window with a real text input at the prompt. Output lines fade in with a soft phosphor glow over faint scanlines, the up and down arrows walk through your history and Tab completes known commands. It understands help, ls, date, whoami, echo and clear, which is enough for developer portfolios, docs and playful 404 pages.

Swap the phosphor and screen colors for amber on brown or white on navy. Replace the command table in the script with your own answers, for example contact details or project links, and keep the window narrow so it reads like a real shell.

## Code

### HTML

```html
<div class="uvq06-tm"><div class="bar" aria-hidden="true"><i></i><i></i><i></i><span>zsh · 64×12</span></div><div class="out" role="log" aria-live="polite"><p class="dim">Type help and press Enter</p></div><form class="ln"><label for="uvq06-tm-in" class="pr"><span class="sr">Command</span><b>~/web</b> ❯</label><input id="uvq06-tm-in" autocomplete="off" spellcheck="false" enterkeyhint="send"></form></div>
```

### CSS

```css
.uvq06-tm {
  --c1: #4ade80;
  --c2: #0c1410;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-tm {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  border-radius: .8em;
  overflow: hidden;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: var(--c1);
  background: var(--c2);
  box-shadow: 0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.6em -1.2em rgba(0,0,0,.6);
  cursor: text;
}

.uvq06-tm:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-tm .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-tm::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,rgba(255,255,255,.03) 0 1px,transparent 1px 3px);
}

.uvq06-tm .bar {
  display: flex;
  align-items: center;
  gap: .4em;
  padding: .6em .8em;
  background: color-mix(in srgb,var(--c2) 88%,#fff);
}

.uvq06-tm .bar i {
  width: .68em;
  height: .68em;
  border-radius: 50%;
  background: #ff5f57;
}

.uvq06-tm .bar i:nth-child(2) {
  background: #febc2e;
}

.uvq06-tm .bar i:nth-child(3) {
  background: #28c840;
}

.uvq06-tm .bar span {
  flex: 1;
  margin-right: 2.5em;
  font-size: .68em;
  text-align: center;
  color: rgba(255,255,255,.45);
}

.uvq06-tm .out {
  height: 7.6em;
  overflow-y: auto;
  padding: .6em .9em 0;
  font-size: .8em;
  line-height: 1.55;
  scrollbar-width: none;
}

.uvq06-tm .out p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
  animation: uvq06-tm calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tm .out .dim {
  color: color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm .out .er {
  color: #ff7b72;
}

.uvq06-tm b {
  font-weight: 600;
  color: #79c0ff;
}

.uvq06-tm .ln {
  display: flex;
  align-items: center;
  gap: .5em;
  margin: 0;
  padding: .2em .9em .85em;
  font-size: .8em;
}

.uvq06-tm .pr {
  white-space: nowrap;
  cursor: text;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: inherit;
  caret-color: var(--c1);
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

@keyframes uvq06-tm {
  from {
    opacity: 0;
    transform: translateY(.3em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-tm,.uvq06-tm *,.uvq06-tm *::before,.uvq06-tm *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq06-tm").forEach(el => {
  const out=el.querySelector(".out"),i=el.querySelector("input"),f=el.querySelector("form");const C=["help","ls","date","whoami","echo","clear"],H=[];let h=0;
const line=(t,c)=>{const p=document.createElement("p");if(c)p.className=c;p.textContent=t;out.append(p);while(out.children.length>40)out.firstChild.remove();out.scrollTop=out.scrollHeight};
const echo=t=>{const p=document.createElement("p"),b=document.createElement("b");b.textContent="~/web ❯ ";p.append(b,t);out.append(p)};
const R={help:()=>"Commands: "+C.join(", "),ls:()=>"index.html  styles.css  app.js  img/",date:()=>new Date().toLocaleString(),whoami:()=>"guest",echo:a=>a.join(" ")};
const run=s=>{const[c,...a]=s.trim().split(/\s+/);if(!c)return;if(c==="clear"){out.textContent="";return}if(C.includes(c))line(R[c](a));else line("zsh: command not found: "+c,"er")};
f.addEventListener("submit",e=>{e.preventDefault();const s=i.value;echo(s);if(s.trim())H.push(s);h=H.length;run(s);i.value="";out.scrollTop=out.scrollHeight});
i.addEventListener("keydown",e=>{if(e.key==="ArrowUp"&&h>0){e.preventDefault();i.value=H[--h]}else if(e.key==="ArrowDown"&&H.length){e.preventDefault();h=Math.min(H.length,h+1);i.value=H[h]||""}else if(e.key==="Tab"&&i.value){const m=C.find(c=>c.startsWith(i.value));if(m){e.preventDefault();i.value=m+" "}}});
el.addEventListener("click",()=>{if(!String(getSelection()))i.focus()});
echo("ls");run("ls")
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-tm {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  border-radius: .8em;
  overflow: hidden;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: var(--c1);
  background: var(--c2);
  box-shadow: 0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.6em -1.2em rgba(0,0,0,.6);
  cursor: text;
}

.uvq06-tm:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-tm .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-tm::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,rgba(255,255,255,.03) 0 1px,transparent 1px 3px);
}

.uvq06-tm .bar {
  display: flex;
  align-items: center;
  gap: .4em;
  padding: .6em .8em;
  background: color-mix(in srgb,var(--c2) 88%,#fff);
}

.uvq06-tm .bar i {
  width: .68em;
  height: .68em;
  border-radius: 50%;
  background: #ff5f57;
}

.uvq06-tm .bar i:nth-child(2) {
  background: #febc2e;
}

.uvq06-tm .bar i:nth-child(3) {
  background: #28c840;
}

.uvq06-tm .bar span {
  flex: 1;
  margin-right: 2.5em;
  font-size: .68em;
  text-align: center;
  color: rgba(255,255,255,.45);
}

.uvq06-tm .out {
  height: 7.6em;
  overflow-y: auto;
  padding: .6em .9em 0;
  font-size: .8em;
  line-height: 1.55;
  scrollbar-width: none;
}

.uvq06-tm .out p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
  animation: uvq06-tm calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tm .out .dim {
  color: color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm .out .er {
  color: #ff7b72;
}

.uvq06-tm b {
  font-weight: 600;
  color: #79c0ff;
}

.uvq06-tm .ln {
  display: flex;
  align-items: center;
  gap: .5em;
  margin: 0;
  padding: .2em .9em .85em;
  font-size: .8em;
}

.uvq06-tm .pr {
  white-space: nowrap;
  cursor: text;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: inherit;
  caret-color: var(--c1);
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

@keyframes uvq06-tm {
  from {
    opacity: 0;
    transform: translateY(.3em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-tm,.uvq06-tm *,.uvq06-tm *::before,.uvq06-tm *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const out=el.querySelector(".out"),i=el.querySelector("input"),f=el.querySelector("form");const C=["help","ls","date","whoami","echo","clear"],H=[];let h=0;
const line=(t,c)=>{const p=document.createElement("p");if(c)p.className=c;p.textContent=t;out.append(p);while(out.children.length>40)out.firstChild.remove();out.scrollTop=out.scrollHeight};
const echo=t=>{const p=document.createElement("p"),b=document.createElement("b");b.textContent="~/web ❯ ";p.append(b,t);out.append(p)};
const R={help:()=>"Commands: "+C.join(", "),ls:()=>"index.html  styles.css  app.js  img/",date:()=>new Date().toLocaleString(),whoami:()=>"guest",echo:a=>a.join(" ")};
const run=s=>{const[c,...a]=s.trim().split(/\s+/);if(!c)return;if(c==="clear"){out.textContent="";return}if(C.includes(c))line(R[c](a));else line("zsh: command not found: "+c,"er")};
f.addEventListener("submit",e=>{e.preventDefault();const s=i.value;echo(s);if(s.trim())H.push(s);h=H.length;run(s);i.value="";out.scrollTop=out.scrollHeight});
i.addEventListener("keydown",e=>{if(e.key==="ArrowUp"&&h>0){e.preventDefault();i.value=H[--h]}else if(e.key==="ArrowDown"&&H.length){e.preventDefault();h=Math.min(H.length,h+1);i.value=H[h]||""}else if(e.key==="Tab"&&i.value){const m=C.find(c=>c.startsWith(i.value));if(m){e.preventDefault();i.value=m+" "}}});
el.addEventListener("click",()=>{if(!String(getSelection()))i.focus()});
echo("ls");run("ls")
}

export default function InTerminal() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#4ade80",
          "--c2": "#0c1410",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-tm"><div className="bar" aria-hidden="true"><i></i><i></i><i></i><span>zsh · 64×12</span></div><div className="out" role="log" aria-live="polite"><p className="dim">Type help and press Enter</p></div><form className="ln"><label htmlFor="uvq06-tm-in" className="pr"><span className="sr">Command</span><b>~/web</b> ❯</label><input id="uvq06-tm-in" autoComplete="off" spellCheck="false" enterKeyHint="send" /></form></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Command line input” block (Inputs) from AIMRAN Library to my project.

## What it is
A green phosphor console: type commands, bring back earlier ones with the arrow keys and complete them with Tab.

## Chosen settings
- Main color: #4ade80
- Secondary color: #0c1410
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Orden"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-tm {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 21em;
  border-radius: .8em;
  overflow: hidden;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color: var(--c1);
  background: var(--c2);
  box-shadow: 0 0 0 1px rgba(255,255,255,.07),0 1.4em 2.6em -1.2em rgba(0,0,0,.6);
  cursor: text;
}

.uvq06-tm:has(input:focus-visible) {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-tm .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-tm::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,rgba(255,255,255,.03) 0 1px,transparent 1px 3px);
}

.uvq06-tm .bar {
  display: flex;
  align-items: center;
  gap: .4em;
  padding: .6em .8em;
  background: color-mix(in srgb,var(--c2) 88%,#fff);
}

.uvq06-tm .bar i {
  width: .68em;
  height: .68em;
  border-radius: 50%;
  background: #ff5f57;
}

.uvq06-tm .bar i:nth-child(2) {
  background: #febc2e;
}

.uvq06-tm .bar i:nth-child(3) {
  background: #28c840;
}

.uvq06-tm .bar span {
  flex: 1;
  margin-right: 2.5em;
  font-size: .68em;
  text-align: center;
  color: rgba(255,255,255,.45);
}

.uvq06-tm .out {
  height: 7.6em;
  overflow-y: auto;
  padding: .6em .9em 0;
  font-size: .8em;
  line-height: 1.55;
  scrollbar-width: none;
}

.uvq06-tm .out p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
  animation: uvq06-tm calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-tm .out .dim {
  color: color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm .out .er {
  color: #ff7b72;
}

.uvq06-tm b {
  font-weight: 600;
  color: #79c0ff;
}

.uvq06-tm .ln {
  display: flex;
  align-items: center;
  gap: .5em;
  margin: 0;
  padding: .2em .9em .85em;
  font-size: .8em;
}

.uvq06-tm .pr {
  white-space: nowrap;
  cursor: text;
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

.uvq06-tm input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: inherit;
  caret-color: var(--c1);
  text-shadow: 0 0 .45em color-mix(in srgb,var(--c1) 55%,transparent);
}

@keyframes uvq06-tm {
  from {
    opacity: 0;
    transform: translateY(.3em);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-tm,.uvq06-tm *,.uvq06-tm *::before,.uvq06-tm *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const out=el.querySelector(".out"),i=el.querySelector("input"),f=el.querySelector("form");const C=["help","ls","date","whoami","echo","clear"],H=[];let h=0;
const line=(t,c)=>{const p=document.createElement("p");if(c)p.className=c;p.textContent=t;out.append(p);while(out.children.length>40)out.firstChild.remove();out.scrollTop=out.scrollHeight};
const echo=t=>{const p=document.createElement("p"),b=document.createElement("b");b.textContent="~/web ❯ ";p.append(b,t);out.append(p)};
const R={help:()=>"Commands: "+C.join(", "),ls:()=>"index.html  styles.css  app.js  img/",date:()=>new Date().toLocaleString(),whoami:()=>"guest",echo:a=>a.join(" ")};
const run=s=>{const[c,...a]=s.trim().split(/\s+/);if(!c)return;if(c==="clear"){out.textContent="";return}if(C.includes(c))line(R[c](a));else line("zsh: command not found: "+c,"er")};
f.addEventListener("submit",e=>{e.preventDefault();const s=i.value;echo(s);if(s.trim())H.push(s);h=H.length;run(s);i.value="";out.scrollTop=out.scrollHeight});
i.addEventListener("keydown",e=>{if(e.key==="ArrowUp"&&h>0){e.preventDefault();i.value=H[--h]}else if(e.key==="ArrowDown"&&H.length){e.preventDefault();h=Math.min(H.length,h+1);i.value=H[h]||""}else if(e.key==="Tab"&&i.value){const m=C.find(c=>c.startsWith(i.value));if(m){e.preventDefault();i.value=m+" "}}});
el.addEventListener("click",()=>{if(!String(getSelection()))i.focus()});
echo("ls");run("ls")
}

export default function InTerminal() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#4ade80",
          "--c2": "#0c1410",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-tm"><div className="bar" aria-hidden="true"><i></i><i></i><i></i><span>zsh · 64×12</span></div><div className="out" role="log" aria-live="polite"><p className="dim">Type help and press Enter</p></div><form className="ln"><label htmlFor="uvq06-tm-in" className="pr"><span className="sr">Command</span><b>~/web</b> ❯</label><input id="uvq06-tm-in" autoComplete="off" spellCheck="false" enterKeyHint="send" /></form></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
