Patterns · Dashboard
BrowserPreview
A simple browser window with an address bar around a screenshot or any content. Use it to show which website a page is about, or to preview a restore point or a staging copy.
import { BrowserPreview } from '@statix/ui/browser-preview';Examples
Screenshot
Pass src and alt. The image fills the window from the top.
<script lang="ts">
import { BrowserPreview } from '@statix/ui/browser-preview';
// Stand-in screenshot. In the app, use the real screenshot URL from the API.
const screenshot =
'data:image/svg+xml;utf8,' +
encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" width="1120" height="800" font-family="sans-serif"><rect width="1120" height="800" fill="#F9FAFB"/><rect width="1120" height="104" fill="#fff"/><text x="56" y="62" font-size="30" font-weight="600" fill="#245240">Yoga Berger</text><rect y="104" width="1120" height="320" fill="#245240"/><text x="56" y="230" font-size="52" font-weight="600" fill="#fff">Yoga in Hamburg-Eppendorf</text><text x="56" y="290" font-size="26" fill="#fff" opacity=".85">Hatha, Yin and prenatal classes. First class free.</text><rect x="56" y="464" width="320" height="200" rx="24" fill="#fff"/><rect x="400" y="464" width="320" height="200" rx="24" fill="#fff"/><rect x="744" y="464" width="320" height="200" rx="24" fill="#fff"/></svg>`
);
</script>
<BrowserPreview
url="yoga-berger.de"
src={screenshot}
alt="Start page of yoga-berger.de"
class="h-[400px] w-full max-w-[560px]"
/>Custom content
Pass children for a live mock, an iframe or a skeleton while the screenshot loads.
Monday
18:00 Hatha
Wednesday
19:30 Yin
Saturday
10:00 Flow
<script lang="ts">
import { BrowserPreview } from '@statix/ui/browser-preview';
</script>
<BrowserPreview url="yoga-berger.de/kursplan" class="h-[320px] w-full max-w-[560px]">
<div class="flex h-full flex-col">
<div class="flex h-12 items-center justify-between bg-card px-6">
<span class="text-subtitle font-semibold text-ink">Yoga Berger</span>
<span class="text-small text-ink-2">Classes · Prices · About · Contact</span>
</div>
<div class="grid flex-1 grid-cols-3 gap-3 p-6">
{#each [['Monday', '18:00 Hatha'], ['Wednesday', '19:30 Yin'], ['Saturday', '10:00 Flow']] as [day, slot] (day)}
<div class="rounded-sm bg-card p-3.5">
<p class="text-label text-ink">{day}</p>
<p class="text-small text-ink-2">{slot}</p>
</div>
{/each}
</div>
</div>
</BrowserPreview>Staging copy with caption
Set secure={false} for addresses without a certificate and add a caption to explain what the reader sees.
<script lang="ts">
import { BrowserPreview } from '@statix/ui/browser-preview';
import { Skeleton } from '@statix/ui/skeleton';
</script>
<BrowserPreview
url="staging.yoga-berger.de"
secure={false}
caption="Test copy from today, 09:30. Visitors still see the live site."
class="w-full max-w-[560px]"
>
<div class="flex h-[240px] flex-col gap-3 p-6">
<Skeleton class="h-8 w-1/2" />
<Skeleton class="h-4 w-3/4" />
<Skeleton class="h-4 w-2/3" />
<Skeleton class="mt-auto h-24 w-full" />
</div>
</BrowserPreview>Guidelines
Do
- Give the window a fixed height or aspect ratio with class, for example class="h-[400px]".
- Show the address the customer knows, without https://.
Don't
- Don’t make the frame clickable. Put a link or button next to it.
- Don’t use it for non-website content.
Accessibility
- Renders a <figure>; the optional caption becomes its <figcaption>.
- The window dots are hidden. The lock icon is hidden too, and visually hidden text ("Secure connection:", override with secureLabel) reads before the address.
- Screenshots need meaningful alt text, for example "Start page of yoga-berger.de".
API reference
BrowserPreview
renders<figure> and accepts its attributes| Prop | Type | Default |
|---|---|---|
url * | string Address in the bar. | – |
src | string Screenshot URL. Ignored when children are passed. | – |
alt | string Alt text for the screenshot. | '' |
secure | boolean Shows the lock icon. | true |
secureLabel | string Screen reader text for the lock. | 'Secure connection' |
caption | string Caption under the window. | – |
children | Snippet Content of the window. | – |
ref bind | HTMLElement | null The root element. | – |
class | ClassValue Merged with the frame classes; yours win. | – |
| Data attribute | Meaning |
|---|---|
data-slot="browser-preview" | Root. Parts use browser-preview-bar, -url, -viewport, -caption. |