Device frame
Phone and browser frames around live, accessible content.
Demo
Usage
import { Button, DeviceFrame, Gradient, Message, Soundwave, Thread } from '@tuttn/slant'
// A compact phone around real content. The frame adds no interaction.
<DeviceFrame title="Voice notes" role="group" aria-label="Phone preview">
<div style={{ padding: 20 }}>
<Thread label="Conversation">
<Message author="assistant">What would you like to remember?</Message>
</Thread>
<Soundwave levels={[0.2, 0.6, 0.9, 0.4, 0.2]} variant="capsules" />
<Button onClick={saveNote}>Save note</Button>
</div>
</DeviceFrame>
// The browser fills its container. Its dots are decoration, not controls.
<DeviceFrame variant="browser" title="Project preview">
<Project />
</DeviceFrame>
// Compose a still backdrop as a sibling, keeping the content accessible.
<div className="preview-stage">
<Gradient variant="ribbon" running={false} className="preview-backdrop" />
<DeviceFrame className="preview-phone"><App /></DeviceFrame>
</div>
.preview-stage { position: relative; isolation: isolate; padding: 32px 12px; }
.preview-backdrop { position: absolute; inset: 0; height: 100%; z-index: -1; }
.preview-phone { margin-inline: auto; --sl-device-frame-height: 30rem; }Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'phone' | 'browser' | 'phone' | A compact phone shell or a full-width browser window. |
title | string | — | A visible title in the decorative chrome. Name meaningful regions with aria-label and role. |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, other attributes and the ref reach the outer frame. Children render inside the scrolling viewport. |
Accessibility
- Only the decorative chrome is aria-hidden; live content keeps its own semantics and tab order.
- The chrome adds no controls or tab stops. An overflowing viewport takes focus for keyboard scrolling; a viewport that fits does not.
- Name the preview with role="group" and aria-label when it needs a region label.
Live content
DeviceFrame supplies a shell for a product preview. Put real components, an image or other content inside; buttons and links keep their normal behaviour. The frame's speaker and browser dots are decorative and take no focus. A frame does not simulate an operating system or change its children's layout.
Sizing
The phone fills the available width up to 300px. The browser fills its container. Both shrink to fit narrow spaces. Their viewports scroll when content is taller than the frame: 30rem for the phone and 22rem for the browser. An overflowing viewport takes keyboard focus so arrow keys can scroll it, even when its content has no buttons or links. Set --sl-device-frame-height to change that height, or style .sl-device-frame-viewport directly. Add padding inside your own content so it can also run edge to edge.
Titles and accessibility
title is a visible chrome label and truncates when it is too long. The chrome is hidden from screen readers; meaningful headings belong inside the viewport. For a named preview, pass role="group" and aria-label to the frame. Its children remain readable and keyboard accessible.