# WebPreview

A sandboxed preview of a web page, with an address bar.

- **Use it for**: A sandboxed preview of a web page with an address bar.
- **Not for**: MCP App views. Try [MCPAppFrame](https://unseenui.com/components/mcp-app-frame/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { WebPreview } from '@stackunseen/ui/devtools';
import '@stackunseen/ui/styles.css';

<WebPreview url={previewUrl} onNavigate={setPreviewUrl} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `className` | `string` |  |
| `error` | `string` | A short host reason shown with `failed` or `unavailable`. |
| `labels` | `Partial<WebPreviewLabels>` | Replaces the built-in wording, for example to translate it. |
| `onNavigate` | `((url: string) => void)` | Called when the person submits a new address. |
| `onReload` | `(() => void)` | Called on Reload and Try again, so the host can check the page and update `status`. |
| `status` | `"ready" \| "unavailable" \| "failed"` | `failed` and `unavailable` come from the host: a page inside a sandboxed frame cannot report that it did not load. |
| `title` | `string` |  |
| `url` (required) | `string` | The host-supplied page to preview. |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[CodeTabs](https://unseenui.com/components/code-tabs/), [Snippet](https://unseenui.com/components/snippet/), [Commit](https://unseenui.com/components/commit/), [EnvironmentVariables](https://unseenui.com/components/environment-variables/), [PackageInfo](https://unseenui.com/components/package-info/), [SchemaDisplay](https://unseenui.com/components/schema-display/), [StackTrace](https://unseenui.com/components/stack-trace/), [Image](https://unseenui.com/components/image/), [FileExplorer](https://unseenui.com/components/file-explorer/), [CodeDiff](https://unseenui.com/components/code-diff/), [TerminalOutput](https://unseenui.com/components/terminal-output/), [TestResults](https://unseenui.com/components/test-results/)

Page: https://unseenui.com/components/web-preview/
