BrowserWindow

A browser-style preview window with navigation controls, an address bar, and an optional element inspector. It renders content via srcdoc or an external preview URL.

Import

import { BrowserWindow } from "@run0/jiki-ui";
import type { InspectedElement } from "@run0/jiki-ui";

Props

PropTypeDefaultDescription
htmlSrcstring—HTML source for the iframe srcdoc
urlstring—Current URL path shown in the address bar
canGoBackboolean—Enable the back button
canGoForwardboolean—Enable the forward button
onBack() => void—Back button callback
onForward() => void—Forward button callback
onRefresh() => void—Refresh button callback
onNavigate(path: string) => void—Called when the user submits a URL
portnumber3000Port number shown in the address bar
titlestring"App Preview"Window title
previewUrlstring—External URL to load instead of srcdoc
onInspectElement(element: InspectedElement) => void—Called when the user inspects a DOM element

InspectedElement

interface InspectedElement {
  tagName: string;       // HTML tag name (lowercase)
  className: string;     // CSS class string
  textContent: string;   // Text content (truncated to 200 chars)
  outerHTML: string;     // Outer HTML (truncated to 500 chars)
}

Features

  • macOS-style browser chrome with traffic lights
  • Back, forward, and refresh navigation buttons
  • Address bar with URL parsing and Enter to navigate
  • Element inspector with crosshair cursor mode
  • Tracks <title> changes via MutationObserver
  • Supports both srcdoc and external preview URLs

Usage

<BrowserWindow
  htmlSrc={html}
  url={currentPath}
  canGoBack={history.length > 1}
  canGoForward={false}
  onBack={() => history.pop()}
  onForward={() => {}}
  onRefresh={() => reloadPreview()}
  onNavigate={(path) => navigateTo(path)}
  port={3000}
  onInspectElement={(el) => console.log(el.tagName)}
/>

Demo