Skip to content

Webcam frameNew

A dashed camera card in the same style as the footer status. The center stays clear on the live route so the camera can sit behind it. On 9:16 the frame covers the top of the phone.

camera

"use client";

import type { CSSProperties } from "react";

import { OverlayRoot } from "@/components/stream/overlay-root";
import { footerConfig } from "@/config/site";
import type { StreamLayout } from "@/config/stream-components";
import { cn } from "@/lib/utils";

const night = {
  "--background": "#000000",
  "--foreground": "oklch(0.985 0 0)",
  "--muted": "oklch(0.269 0 0)",
  "--muted-foreground": "oklch(0.708 0 0)",
  "--border": "oklch(1 0 0 / 18%)",
} as CSSProperties;

export function WebcamFrame({
  layout,
  preview = false,
}: {
  layout: StreamLayout;
  preview?: boolean;
}) {
  const mobile = layout === "mobile";

  return (
    <OverlayRoot>
      <div
        style={night}
        className={cn(
          "absolute text-foreground",
          mobile
            ? "inset-x-0 top-0"
            : "bottom-[5.5cqw] left-[4.2cqw] w-[30cqw]",
        )}
      >
        <div
          className={cn(
            mobile && "overflow-hidden border-x border-b border-dashed",
            mobile && preview && "bg-background/60",
          )}
        >
          <div
            className={cn(
              "relative aspect-video overflow-hidden",
              mobile ? "rounded-none" : "rounded-lg border border-dashed",
              !mobile && (preview ? "bg-background/60" : "bg-transparent"),
            )}
          >
            {preview ? (
              <p
                className={cn(
                  "absolute inset-0 grid place-items-center font-mono tracking-[0.18em] text-muted-foreground uppercase",
                  mobile ? "text-[3.4cqw]" : "text-[1.35cqw]",
                )}
              >
                camera
              </p>
            ) : null}
          </div>
          {mobile ? (
            <div className="relative -mt-[1.05cqw] h-[20cqw]">
              {/* The tall peaks sit inset in the artwork, so the strip is
                  wider than the frame and shifted until those peaks meet
                  both side borders. */}
              {/* eslint-disable-next-line @next/next/no-img-element */}
              <img
                src={footerConfig.artwork.src}
                alt=""
                draggable={false}
                style={{ width: "112%", marginLeft: "-7.5%" }}
                className="pointer-events-none relative block h-auto max-w-none select-none"
              />
            </div>
          ) : null}
        </div>
      </div>
    </OverlayRoot>
  );
}

Props

Layout

Desktop 16:9 for OBS, or mobile 9:16 for TikTok Live Studio.

Installation

Webcam frame is a browser-source overlay. Copy the URL for OBS or TikTok Live Studio. The live page has no site chrome and a transparent background.

In OBS, add a Browser source, paste the URL, and set the size to 1920 × 1080. Leave the page background transparent.

Usage

example.tsx

import { WebcamFrame } from "@/components/stream/webcam-frame";

export function Overlay() {
  return <WebcamFrame layout="desktop" preview />;
}

Browser source

Paste this URL into OBS or TikTok Live Studio. The query params match the props below.

browser-source.tsx

// OBS Browser source, 1920×1080. Leave the hole empty for the camera.
const src = "https://chandlerking.dev/live/webcam-frame?layout=desktop";

A dashed camera card, matching the footer status. Preview shows a camera label in the hole. On the live route the center stays empty so the camera can sit behind it. Desktop sits bottom-left. Mobile covers the top of the 9:16 phone.

Props

PropTypeDefaultNotes
layout"desktop" | "mobile"RequiredCanvas orientation. Desktop is 1920×1080 for OBS. Mobile is 1080×1920 for TikTok Live Studio. Query `layout`.
previewbooleanfalseSite-only helpers: a sample webcam fill, a looping alert, and a stinger replay control. Leave it off on the live route.

Notes & Features

  • Clear hole. The center of the bezel is transparent on the live route. Put the camera source behind this browser source. Preview shows a camera label instead of a photo.
  • Dashed card. The frame uses the footer status card: rounded, dashed border, and a translucent fill in preview. The live hole stays clear.
  • 9:16 placement. Mobile fills the top of the phone. The pine-forest sticker and a dashed rule divide the camera from the gameplay.

Manual installation

Rather than the browser source, copy Webcam frame into a project. Install its dependencies, then copy all 2 files into the matching path.

Source files

src/components/stream/webcam-frame.tsx

"use client";

import type { CSSProperties } from "react";

import { OverlayRoot } from "@/components/stream/overlay-root";
import { footerConfig } from "@/config/site";
import type { StreamLayout } from "@/config/stream-components";
import { cn } from "@/lib/utils";

const night = {
  "--background": "#000000",
  "--foreground": "oklch(0.985 0 0)",
  "--muted": "oklch(0.269 0 0)",
  "--muted-foreground": "oklch(0.708 0 0)",
  "--border": "oklch(1 0 0 / 18%)",
} as CSSProperties;

export function WebcamFrame({
  layout,
  preview = false,
}: {
  layout: StreamLayout;
  preview?: boolean;
}) {
  const mobile = layout === "mobile";

  return (
    <OverlayRoot>
      <div
        style={night}
        className={cn(
          "absolute text-foreground",
          mobile
            ? "inset-x-0 top-0"
            : "bottom-[5.5cqw] left-[4.2cqw] w-[30cqw]",
        )}
      >
        <div
          className={cn(
            mobile && "overflow-hidden border-x border-b border-dashed",
            mobile && preview && "bg-background/60",
          )}
        >
          <div
            className={cn(
              "relative aspect-video overflow-hidden",
              mobile ? "rounded-none" : "rounded-lg border border-dashed",
              !mobile && (preview ? "bg-background/60" : "bg-transparent"),
            )}
          >
            {preview ? (
              <p
                className={cn(
                  "absolute inset-0 grid place-items-center font-mono tracking-[0.18em] text-muted-foreground uppercase",
                  mobile ? "text-[3.4cqw]" : "text-[1.35cqw]",
                )}
              >
                camera
              </p>
            ) : null}
          </div>
          {mobile ? (
            <div className="relative -mt-[1.05cqw] h-[20cqw]">
              {/* The tall peaks sit inset in the artwork, so the strip is
                  wider than the frame and shifted until those peaks meet
                  both side borders. */}
              {/* eslint-disable-next-line @next/next/no-img-element */}
              <img
                src={footerConfig.artwork.src}
                alt=""
                draggable={false}
                style={{ width: "112%", marginLeft: "-7.5%" }}
                className="pointer-events-none relative block h-auto max-w-none select-none"
              />
            </div>
          ) : null}
        </div>
      </div>
    </OverlayRoot>
  );
}

src/components/stream/overlay-root.tsx

import type { ReactNode } from "react";

import { cn } from "@/lib/utils";

export function OverlayRoot({
  children,
  className,
}: {
  children: ReactNode;
  className?: string;
}) {
  return (
    <div
      className={cn(
        "@container relative h-full w-full overflow-hidden pointer-events-none",
        className,
      )}
    >
      {children}
    </div>
  );
}

Carve that warmth into me.

Vinland Saga
Chandler King

Building AnglerIQ & The Sozo CRM

Open to software engineering roles

Crafted by Chandler King · Kansas City, MO