Site
Browser frame
The site's browser window around a screenshot or a live part of a page: a #262626 window with a #4D4D4D hairline, three gray dots, the address in a small pill, and an optional footer row.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add browser-frame<script type="module" src="/spyglass-ds/elements/browser-frame.js"></script>Plans for every team
Start free, upgrade when you need more.
Usage
Showing a product page, a dashboard or a result inside a page or an asset, as the site frames its own screens.
Never
- Colored window dots: they are #666666 on the site
- A drop shadow or a glow around the window
- Another company's site in the address
Props
The web component takes the same as attributes or properties (<spyglass-browser-frame>); title is heading there.
<BrowserFrame>
| Prop | Type | Default |
|---|---|---|
url | string The address in the bar: "acme.com/pricing". | |
footer | ReactNode A row under the page, in DM Sans 14/20. | |
children | ReactNode The page: an image, a video or markup. | |
className | string |
Examples
The same example in React and as web components; both render identically.
import { BrowserFrame } from '@/react/components/site/BrowserFrame'
// A page of Acme's inside the browser window, with a footer row.
export default function Page() {
return (
<div className="h-80 w-full max-w-160">
<BrowserFrame url="acme.com/pricing" footer={<span className="text-fg-muted">Updated today</span>}>
<div className="grid h-full place-content-center gap-2 p-6 text-center">
<p className="type-heading-3">Plans for every team</p>
<p className="type-ui text-fg-soft">Start free, upgrade when you need more.</p>
</div>
</BrowserFrame>
</div>
)
}<!-- A page of Acme's inside the browser window, with a footer row. -->
<div class="h-80 w-full max-w-160">
<spyglass-browser-frame url="acme.com/pricing">
<div class="grid h-full place-content-center gap-2 p-6 text-center">
<p class="type-heading-3">Plans for every team</p>
<p class="type-ui text-fg-soft">Start free, upgrade when you need more.</p>
</div>
<span slot="footer" class="text-fg-muted">Updated today</span>
</spyglass-browser-frame>
</div>Source
import type { ReactNode } from 'react'
import { cn } from '@/react/lib/cn'
// The site's browser window (ui/BrowserFrame) around a screenshot or a live part of a page: a #262626 window with a
// #4D4D4D hairline and the 8px corner, a 28px bar with three #666666 dots and the address centered in a #363636 pill
// (a small lock, the address in #D4D4D4 12/16, cut with an ellipsis), the page under it filling the rest, and an
// optional footer row under a hairline. It holds still; the page inside decides what moves.
export interface BrowserFrameProps {
/** The address in the bar: "acme.com/pricing". */
url: string
/** A row under the page, in DM Sans 14/20. */
footer?: ReactNode
/** The page: an image, a video or markup. */
children?: ReactNode
className?: string
}
export function BrowserFrame({ url, footer, children, className }: BrowserFrameProps) {
return (
<div data-ds="browser-frame" className={cn('flex size-full flex-col overflow-hidden rounded-panel border border-edge-surface bg-surface-raised text-fg', className)}>
<div className="grid h-7 shrink-0 grid-cols-[40px_minmax(0,1fr)_40px] items-center gap-2 border-b border-edge-surface px-2">
<span className="flex gap-1" aria-hidden="true">
<span className="size-2 rounded-full bg-edge-strong" />
<span className="size-2 rounded-full bg-edge-strong" />
<span className="size-2 rounded-full bg-edge-strong" />
</span>
<span className="flex h-5 w-full max-w-50 min-w-0 items-center justify-center gap-1 justify-self-center rounded-ds-sm bg-surface-inset px-2 type-caption text-fg-soft">
<svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" className="size-2 shrink-0 text-fg-muted">
<path d="M4 5V3.5a2 2 0 0 1 4 0V5" fill="none" stroke="currentColor" strokeWidth="1.2" />
<rect x="2.5" y="5" width="7" height="5.5" rx="1" fill="currentColor" />
</svg>
<span className="truncate">{url}</span>
</span>
<span />
</div>
<div className="relative min-h-0 flex-1 overflow-hidden">{children}</div>
{footer && <div className="flex shrink-0 items-center gap-2 border-t border-edge-surface px-3 py-2 type-ui">{footer}</div>}
</div>
)
}
export default BrowserFrame// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import { html, nothing } from 'lit'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import styles from 'virtual:tw'
// BrowserFrame.tsx as <spyglass-browser-frame>: the site's browser window, the `url` in the bar's pill, the default
// slot as the page and the `footer` slot as a row under it.
/**
* @summary The site's browser window around a screenshot or part of a page.
* @slot - The page.
* @slot footer - A row under the page.
*/
export class BrowserFrame extends DsElement {
static styles = [DsElement.styles, styles]
protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="browser-frame"]'))
static properties = { url: {} }
/** The address in the bar. */
url = ''
render() {
return html`<div data-ds="browser-frame" class="flex size-full flex-col overflow-hidden rounded-panel border border-edge-surface bg-surface-raised text-fg"><div class="grid h-7 shrink-0 grid-cols-[40px_minmax(0,1fr)_40px] items-center gap-2 border-b border-edge-surface px-2"><span class="flex gap-1" aria-hidden="true"><span class="size-2 rounded-full bg-edge-strong"></span><span class="size-2 rounded-full bg-edge-strong"></span><span class="size-2 rounded-full bg-edge-strong"></span></span><span class="flex h-5 w-full max-w-50 min-w-0 items-center justify-center gap-1 justify-self-center rounded-ds-sm bg-surface-inset px-2 type-caption text-fg-soft"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" class="size-2 shrink-0 text-fg-muted"><path d="M4 5V3.5a2 2 0 0 1 4 0V5" fill="none" stroke="currentColor" stroke-width="1.2"></path><rect x="2.5" y="5" width="7" height="5.5" rx="1" fill="currentColor"></rect></svg><span class="truncate">${this.url}</span></span><span></span></div><div class="relative min-h-0 flex-1 overflow-hidden"><slot></slot></div>${this.hasSlot('footer') ? html`<div class="flex shrink-0 items-center gap-2 border-t border-edge-surface px-3 py-2 type-ui"><slot name="footer"></slot></div>` : nothing}</div>`
}
}
define('browser-frame', BrowserFrame)Reference: Site ui/BrowserFrame (BrowserFrame.module.css): 28px bar, 8px dots in --line-strong, the address pill 20px tall in --surface-inset with 12/16 text, the window in --surface with a --line-surface hairline and --radius-m.