# CRT monitor

A beige monitor housing with a charcoal bezel, a curved CRT screen, a glass reflection, vents, a model badge and a power key. Whatever you put inside runs on the screen.

Source: https://www.ui95.dev/hardware/crt-monitor

## Examples

```tsx
"use client"

import { CrtMonitor } from "@/components/hardware/crt-monitor"

import type { ShowcaseDemo } from "../types"

function PhosphorScreen() {
  return (
    <div className="flex size-full flex-col justify-center gap-2 bg-[#0c1a10] px-10 font-mono text-2xl text-[#9df5b0]">
      <p>HARDWARE95 MONITOR CM-1</p>
      <p>MEMORY TEST 640K OK</p>
      <p>READY.</p>
    </div>
  )
}

export const demo: ShowcaseDemo = {
  span: "full",
  variants: [
    { label: "on", render: () => <CrtMonitor><PhosphorScreen /></CrtMonitor> },
    { label: "off", render: () => <CrtMonitor defaultOn={false}><PhosphorScreen /></CrtMonitor> },
  ],
}
```

## Installation

```bash
npx shadcn@latest add https://www.ui95.dev/r/crt-monitor.json
```

Run it in a Radix shadcn project that already has the UI95 theme.

Add these items first:

- [hardware](https://www.ui95.dev/hardware/hardware)
- [crt-screen](https://www.ui95.dev/ui/crt-screen)

`components/hardware/crt-monitor.css`

```tsx
[data-part="monitor"] {
  --hw-monitor-width: 720px;
  width: var(--hw-monitor-width);
  max-width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 26px 26px 18px;
  border-radius: 26px;
  background: var(--hw-grain), linear-gradient(165deg, var(--hw-body-hi) -20%, var(--hw-body) 40%, var(--hw-body-lo) 130%);
  background-blend-mode: multiply, normal;
  box-shadow: var(--hw-bevel-raised), 0 3px 0 var(--hw-body-lo), var(--hw-shadow-ambient);
}

[data-part="monitor-bezel"] {
  padding: 22px;
  border-radius: 20px;
  background: radial-gradient(140% 120% at 30% 0%, var(--hw-recess-hi), var(--hw-recess) 60%);
  box-shadow: var(--hw-bevel-recess), 0 1px 0 var(--hw-body-hi);
}

[data-part="monitor-screen"] {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 28px / 22px;
  background: radial-gradient(120% 120% at 50% 45%, #1e2420, #0b0d0c 70%);
  box-shadow: inset 0 0 0 2px #050505, inset 0 0 40px rgb(0 0 0 / 0.8);
}

[data-part="monitor-raster"] {
  position: absolute;
  inset: 0;
  filter: brightness(var(--hw-brightness, 1));
  transform-origin: 50% 50%;
  animation: hw-monitor-warm 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

[data-part="monitor-glass"] {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(70% 45% at 28% 12%, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0) 70%),
    radial-gradient(130% 120% at 50% 50%, rgb(0 0 0 / 0) 60%, rgb(0 0 0 / 0.45) 100%);
  box-shadow: inset 0 0 18px rgb(0 0 0 / 0.55);
}

[data-part="monitor-chin"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px 18px;
  padding: 0 6px;
}

[data-part="monitor-vents"] {
  flex: 1;
  min-width: 40px;
  height: 14px;
  background: repeating-linear-gradient(90deg, var(--hw-recess) 0 3px, transparent 3px 8px);
  opacity: 0.55;
  border-radius: 2px;
  box-shadow: 0 1px 0 var(--hw-body-hi);
}

[data-part="monitor-controls"] {
  display: flex;
  align-items: center;
  gap: 12px;
}

[data-part="monitor-power"] {
  display: flex;
  align-items: center;
  gap: 10px;
}

[data-part="monitor-power-key"] {
  display: grid;
  place-items: center;
  min-width: 64px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--hw-body-hi), var(--hw-body) 60%, var(--hw-body-lo));
  box-shadow: var(--hw-bevel-raised), 0 3px 0 var(--hw-body-lo), 0 4px 6px rgb(var(--hw-shadow-tint) / 0.35);
  cursor: pointer;
  translate: 0 0;
  transition: translate 60ms ease-out, box-shadow 60ms ease-out;
}

[data-part="monitor-power-key"]:active,
[data-part="monitor-power-key"][aria-pressed="true"] {
  translate: 0 2px;
  box-shadow: var(--hw-bevel-raised), 0 1px 0 var(--hw-body-lo), 0 2px 3px rgb(var(--hw-shadow-tint) / 0.35);
}

[data-part="monitor-power-key"]:focus-visible {
  outline: 2px solid var(--hw-amber-lit);
  outline-offset: 2px;
}

@keyframes hw-monitor-warm {
  0% {
    transform: scale(0.6, 0.004);
    filter: brightness(4);
  }
  45% {
    transform: scale(1, 0.01);
    filter: brightness(3);
  }
  100% {
    transform: scale(1, 1);
    filter: brightness(var(--hw-brightness, 1));
  }
}

@media (max-width: 640px) {
  [data-part="monitor"] {
    padding: 16px 16px 14px;
    border-radius: 20px;
  }

  [data-part="monitor-bezel"] {
    padding: 12px;
  }

  [data-part="monitor-vents"] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-part="monitor-raster"] {
    animation: none;
  }

  [data-part="monitor-power-key"] {
    transition: none;
  }
}
```

`components/hardware/crt-monitor.tsx`

```tsx
"use client"

import "./hardware.css"
import "./crt-monitor.css"

import * as React from "react"

import { CrtScreen } from "@/components/retro/crt-screen"

import { Legend } from "./faceplate"
import { Lamp } from "./lamp"

type CrtMonitorProps = Omit<React.ComponentProps<"div">, "children"> & {
  children: React.ReactNode
  on?: boolean
  defaultOn?: boolean
  onPowerChange?: (on: boolean) => void
  brightness?: number
  curvature?: number
  model?: string
  controls?: React.ReactNode
}

function CrtMonitor({
  children,
  on: controlled,
  defaultOn = true,
  onPowerChange,
  brightness = 1,
  curvature = 0.08,
  model = "Hardware95 · CM-1",
  controls,
  style,
  ...props
}: CrtMonitorProps) {
  const [stored, setStored] = React.useState(defaultOn)
  const isOn = controlled ?? stored
  const toggle = () => {
    setStored(!isOn)
    onPowerChange?.(!isOn)
  }
  const screenStyle = { ...style, "--hw-brightness": String(brightness) } as React.CSSProperties

  return (
    <div data-hw="" data-part="monitor" data-on={isOn ? "" : undefined} style={screenStyle} {...props}>
      <div data-part="monitor-bezel">
        <div data-part="monitor-screen">
          {isOn && (
            <div data-part="monitor-raster">
              <CrtScreen className="size-full" preset="subtle" curvature={curvature}>
                {children}
              </CrtScreen>
            </div>
          )}
          <span aria-hidden data-part="monitor-glass" />
        </div>
      </div>
      <div data-part="monitor-chin">
        <Legend size="sm">{model}</Legend>
        <span aria-hidden data-part="monitor-vents" />
        {controls && <div data-part="monitor-controls">{controls}</div>}
        <div data-part="monitor-power">
          <Lamp on={isOn} tone="green" />
          <button type="button" data-part="monitor-power-key" data-slot="button" aria-pressed={isOn} onClick={toggle}>
            <Legend size="sm">Power</Legend>
          </button>
        </div>
      </div>
    </div>
  )
}

export { CrtMonitor }
```

## Notes

Render any content as children; it runs inside the CRT effect from crt-screen. on and onPowerChange control it, or pass defaultOn={false} to start dark. brightness (0.4 to 1.4) and curvature set the picture. Put knobs or lamps in the controls slot and they sit in the chin next to the power key. Turning it on plays a short warm-up that reduced motion skips.

## API reference

### CrtMonitor

| Prop | Type | Default |
| --- | --- | --- |
| `children` * | `React.ReactNode` | - |
| `on` | `boolean` | - |
| `defaultOn` | `boolean` | `true` |
| `onPowerChange` | `((on: boolean) => void)` | - |
| `brightness` | `number` | `1` |
| `curvature` | `number` | `0.08` |
| `model` | `string` | `"Hardware95 · CM-1"` |
| `controls` | `React.ReactNode` | - |
