Layout
PreviewStage
A resizable device frame for showing a component or a whole page at 390, 768, 1280 or any width, themed in its own light or dark island.
<script>
import { PreviewStage } from "@codeatlasdev/ui";
let width = $state("fill");
</script>
<PreviewStage label="Pricing" bind:width scheme="dark">
<Pricing />
</PreviewStage>
<PreviewStage label="Dashboard" src="/templates/app/dashboard/" height={720} />
For your own showcases, design reviews and docs. A width control (presets plus a draggable splitter) sets the frame width in CSS pixels. When the stage is narrower than the chosen width, the whole frame is scaled down, so a 1280 px page still lays out at 1280 px. The stage has a fixed height up front, so content that loads late never shifts what is below it.
Two modes. With children the content is inline and themed in its own ThemeIsland (scheme, preset), so a light or dark switch never touches the page around it. With src a same-origin page loads in an <iframe>: isolated styles, real viewport width, real media queries. Use src for full pages.
Inline content
A component at phone width with a light and dark toggle in the toolbar.
Reference #986 · Pick in the gallery
Code
A whole page
A template in an isolated iframe; switch the width to see its media queries.
Reference #987 · Pick in the gallery
Code
Keyboard
The splitter on the frame’s trailing edge is a WAI-ARIA window splitter (role="separator", focusable): aria-valuenow is the width in px. Arrows move 10 px, Shift plus an arrow 100 px, Home and End go to the smallest and largest width.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | – | Accessible name of the stage (what it shows). Required. |
width | number | 'fill' | 'fill' | Frame width in px, or the whole stage. Bindable. |
widths | number[] | [390, 768, 1280] | Width presets; Fill is always offered. |
scheme | 'light' | 'dark' | 'inherit' | 'inherit' | Scheme of inline content. `inherit` keeps the page's. |
preset | string | undefined | `data-preset` of inline content. |
src | string | undefined | Same-origin page to show in an iframe. Ignored when `children` is given. |
height | number | 560 | Stage height in px. |
minWidth | number | 280 | Smallest width the splitter reaches. |
toolbar | Snippet | undefined | Extra controls after the width control. |
class | string | '' | Extra class names. |