1 GitHub star = 1 new component.

Page Sections terminalmonitorthree3dportfolio

Dev Monitor 3D

3D CRT monitor with ink outlines that drops into place, sways with the cursor and types terminal lines on an inverted screen.

Live Preview

Usage

Copy and paste this code into your Astro page:

astro
---
import { DevMonitor } from 'astro-component-kit/sections';
---

<!-- npm install three -->
<DevMonitor lines={['$ npm run build', '> built in 1.2s']} />
--- import { DevMonitor } from 'astro-component-kit/sections'; --- <!-- npm install three --> <DevMonitor lines={['$ npm run build', '> built in 1.2s']} />

Examples in context

Real code from the kit: how this piece is used inside templates, sections and other components.

Template Developer Portfolio PortfolioContactPage.astro
astro
<DevMonitor
  lines={['$ ping ' + site.githubUser, '> 64 bytes: time=0.4ms', '$ status --availability', `> ${site.status.toLowerCase()}`, '$ mail --to hello', '> ready when you are']}
  prompt="guest@contact:~$"
  height="340px"
  label="Contact terminal"
/>
<DevMonitor lines={['$ ping ' + site.githubUser, '> 64 bytes: time=0.4ms', '$ status --availability', `> ${site.status.toLowerCase()}`, '$ mail --to hello', '> ready when you are']} prompt="guest@contact:~$" height="340px" label="Contact terminal" />

Used in

Manual Installation

If you are not using the npm package, create a new file and paste the following code: src/components/lib/DevMonitor3D.astro:

astro
---
/**
 * DevMonitor — 3D CRT monitor ("Keycap" design): a paper body with ink outlines that drops into
 * place, sways with the cursor and types terminal lines on an inverted screen. Use it as a visual
 * in heroes or project pages. Light/dark aware. Needs the optional `three` peer dependency.
 *
 * @param {string[]} lines - Lines typed in a loop. Lines starting with "$ " get the prompt.
 * @param {string} prompt - Shell prompt. Default 'dev@keycap:~$'.
 * @param {string} height - Canvas height. Default '420px'.
 * @param {string} label - Accessible description. Default 'Terminal on a 3D monitor'.
 * @param {string} className - Extra class.
 *
 * Accessibility: role="img" whose label includes the terminal lines; reduced motion shows every
 * line at once with no drop or typing.
 */
interface Props {
  lines?: string[];
  prompt?: string;
  height?: string;
  label?: string;
  className?: string;
}

const { lines = ['$ whoami', '> full-stack developer'], prompt = 'dev@keycap:~$', height = '420px', label = 'Terminal on a 3D monitor', className = '' } = Astro.props;
---

<div
  class:list={['dvmn', className]}
  style={`--dvmn-h:${height}`}
  data-dev-monitor
  data-lines={JSON.stringify(lines)}
  data-prompt={prompt}
  role="img"
  aria-label={`${label}: ${lines.join(' — ')}`}
></div>

<style>
  .dvmn {
    --kc-ink: var(--c-text-1);
    --kc-paper: var(--c-bg);
    --kc-muted: var(--c-text-3);
    position: relative;
    width: 100%;
    height: var(--dvmn-h);
  }
</style>

<script>
  import * as THREE from 'three';
  import { mountMonitor } from '../three/monitor-scene';

  document.querySelectorAll<HTMLElement>('[data-dev-monitor]:not([data-bound])').forEach((el) => {
    el.dataset.bound = '';
    mountMonitor(el, THREE, { lines: JSON.parse(el.dataset.lines || '[]'), prompt: el.dataset.prompt });
  });
</script>
--- /** * DevMonitor — 3D CRT monitor ("Keycap" design): a paper body with ink outlines that drops into * place, sways with the cursor and types terminal lines on an inverted screen. Use it as a visual * in heroes or project pages. Light/dark aware. Needs the optional `three` peer dependency. * * @param {string[]} lines - Lines typed in a loop. Lines starting with "$ " get the prompt. * @param {string} prompt - Shell prompt. Default 'dev@keycap:~$'. * @param {string} height - Canvas height. Default '420px'. * @param {string} label - Accessible description. Default 'Terminal on a 3D monitor'. * @param {string} className - Extra class. * * Accessibility: role="img" whose label includes the terminal lines; reduced motion shows every * line at once with no drop or typing. */ interface Props { lines?: string[]; prompt?: string; height?: string; label?: string; className?: string; } const { lines = ['$ whoami', '> full-stack developer'], prompt = 'dev@keycap:~$', height = '420px', label = 'Terminal on a 3D monitor', className = '' } = Astro.props; --- <div class:list={['dvmn', className]} style={`--dvmn-h:${height}`} data-dev-monitor data-lines={JSON.stringify(lines)} data-prompt={prompt} role="img" aria-label={`${label}: ${lines.join(' — ')}`} ></div> <style> .dvmn { --kc-ink: var(--c-text-1); --kc-paper: var(--c-bg); --kc-muted: var(--c-text-3); position: relative; width: 100%; height: var(--dvmn-h); } </style> <script> import * as THREE from 'three'; import { mountMonitor } from '../three/monitor-scene'; document.querySelectorAll<HTMLElement>('[data-dev-monitor]:not([data-bound])').forEach((el) => { el.dataset.bound = ''; mountMonitor(el, THREE, { lines: JSON.parse(el.dataset.lines || '[]'), prompt: el.dataset.prompt }); }); </script>

Quick Info

Category
Page Sections
Filename
DevMonitor3D.astro
Dependencies
None — pure Astro + CSS
Tags
terminalmonitorthree3dportfolio