<div class="demo-caption">One app, three widths</div>
<ray-group justify="space-between" class="demo-device-bar">
<ray-segmented-control id="demo-shell-width" value="phone" size="xs" aria-label="Frame width">
<option value="phone">Phone · 390</option>
<option value="tablet">Tablet · 820</option>
<option value="desktop">Desktop · full</option>
</ray-segmented-control>
<span class="demo-muted" id="demo-shell-mode">phone layout: app bar, content, bottom nav</span>
</ray-group>
<div class="demo-device" id="demo-device" data-size="phone">
<iframe id="demo-shell-frame" src="../src/components/app-shell/demo.html" title="ray-app-shell demo: an app in a device"></iframe>
</div>
<p class="demo-muted">The app is a page of its own (<a href="../src/components/app-shell/demo.html" target="_blank" rel="noopener">open it</a>) in an iframe: its drawers, menus and sheets open inside the device, and the shell picks its layout from the frame's width.</p>
<script type="module">
const device = document.getElementById("demo-device");
const frame = document.getElementById("demo-shell-frame");
const label = document.getElementById("demo-shell-mode");
document.getElementById("demo-shell-width").addEventListener("change", (e) => { device.dataset.size = e.target.value; });
const watch = () => {
const shell = frame.contentDocument?.querySelector("ray-app-shell");
if (!shell) return;
const mode = () => {
label.textContent = shell.mobile ? "phone layout: app bar, content, bottom nav" : "wide layout: header, sidebar, content, aside";
};
shell.addEventListener("ray-breakpoint", mode);
frame.contentWindow.customElements.whenDefined("ray-app-shell").then(mode);
};
frame.addEventListener("load", watch);
if (frame.contentDocument?.readyState === "complete") watch();
</script>
import { RayGroup, RaySegmentedControl } from "@raylang/react";
export function AppShellExample() {
return (
<>
<div className="demo-caption">One app, three widths</div>
<RayGroup justify="space-between" className="demo-device-bar">
<RaySegmentedControl id="demo-shell-width" value="phone" size="xs" aria-label="Frame width">
<option value="phone">Phone · 390</option>
<option value="tablet">Tablet · 820</option>
<option value="desktop">Desktop · full</option>
</RaySegmentedControl>
<span className="demo-muted" id="demo-shell-mode">phone layout: app bar, content, bottom nav</span>
</RayGroup>
<div className="demo-device" id="demo-device" data-size="phone">
<iframe id="demo-shell-frame" src="../src/components/app-shell/demo.html" title="ray-app-shell demo: an app in a device" />
</div>
<p className="demo-muted">The app is a page of its own (<a href="../src/components/app-shell/demo.html" target="_blank" rel="noopener">open it</a>) in an iframe: its drawers, menus and sheets open inside the device, and the shell picks its layout from the frame's width.</p>
</>
);
}
<template>
<div class="demo-caption">One app, three widths</div>
<RayGroup justify="space-between" class="demo-device-bar">
<RaySegmentedControl id="demo-shell-width" value="phone" size="xs" aria-label="Frame width">
<option value="phone">Phone · 390</option>
<option value="tablet">Tablet · 820</option>
<option value="desktop">Desktop · full</option>
</RaySegmentedControl>
<span class="demo-muted" id="demo-shell-mode">phone layout: app bar, content, bottom nav</span>
</RayGroup>
<div class="demo-device" id="demo-device" data-size="phone">
<iframe id="demo-shell-frame" src="../src/components/app-shell/demo.html" title="ray-app-shell demo: an app in a device"></iframe>
</div>
<p class="demo-muted">The app is a page of its own (<a href="../src/components/app-shell/demo.html" target="_blank" rel="noopener">open it</a>) in an iframe: its drawers, menus and sheets open inside the device, and the shell picks its layout from the frame's width.</p>
</template>