Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / More

DeviceFrame

A phone, tablet or browser window drawn in CSS around a screenshot, a video or a live demo. The screen keeps its ratio at any width and clips its content to its rounded corners.

Phone

When to useLink to "When to use"

  • Landing pages: an app screenshot or a live demo shown on the device it runs on.
  • Docs and store listings: a screenshot that needs context (a phone layout, a browser page).

Use something else when:

  • the picture needs no device around it: Image, or AspectRatio for a video or an embed
  • the content is a framed surface of the page itself: Card

UsageLink to "Usage"

tsx
Copy
import { DeviceFrame } from "@arshad-shah/cynosure";

<DeviceFrame>
  <img src="/home.png" alt="The app's home screen" />
</DeviceFrame>

<DeviceFrame device="tablet" orientation="landscape" label="The editor on a tablet">
  <img src="/editor.png" alt="" />
</DeviceFrame>

<DeviceFrame device="browser" url="example.com/pricing">
  <PricingDemo />
</DeviceFrame>

device is phone (default), tablet or browser. The frame is as wide as its container, up to a token width for a phone (288px) or a tablet (576px); set style={{ inlineSize: … }} for another width. Everything inside scales with it.

Browser windowLink to "Browser window"

The browser bar has three drawn dots and an optional url. The address is decoration: it is not a link and is not announced. Long addresses are cut with an ellipsis.

Browser window

Orientation and ratioLink to "Orientation and ratio"

orientation="landscape" turns a phone or tablet: the screen's ratio is swapped and the camera moves to the left edge. A landscape device is as tall as its upright one is wide. ratio sets the screen's width ÷ height upright (phone 9 / 19.5, tablet 3 / 4, browser 16 / 10 by default); landscape uses its inverse.

Landscape turns the screen

PropsLink to "Props"

Every prop of DeviceFrame
PropWhat it doesTypeDefault
device
The device drawn around the content. Default "phone".DeviceFrameDevice"phone"
orientation
Which way a phone or tablet is held. The browser ignores it. Default "portrait"."portrait" | "landscape""portrait"
ratio
Width divided by height of the screen, as drawn in portrait (phone and tablet) or as is (browser). Landscape uses its inverse. Default: 9 / 19.5 for a phone, 3 / 4 for a tablet, 16 / 10 for a browser.number9 / 19
url
Address shown in the browser bar (decoration: it is not a link and is not announced). Browser only.string
label
Accessible name. With it the frame is a figure with this name; without it the frame is decoration and adds nothing to the accessibility tree, so the content keeps its own semantics.string
safeArea
Phone only: keep the content clear of the camera island (below it upright, beside it turned), as an app keeps clear of a real phone's. By default live content is kept clear and a screenshot, video or canvas fills the whole screen (it has its own status bar); true or false decides for any content.boolean
children
What the screen shows: a screenshot, a video or a live demo. Each child is stretched to the screen and clipped.ReactNode
className
Added to the root element, for layout.string
style
Layout only (width, margin, placement). The height follows from the width. Restyle through tokens.CSSProperties

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Behaviour and accessibility, table 1
SituationResult
The container gets wider or narrowerThe screen keeps its ratio; a phone's or tablet's bezel and corners scale with it
Content is bigger than the screenIt is clipped to the screen and its rounded corners
A child is an image or a videoIt covers the screen (object-fit: cover)
Dark modeA phone or tablet stays dark, with an edge line; the screen and the browser window follow the theme
ratio is 0, negative or not finiteThe device's own ratio is used
  • Decorative by default: without label the frame is a plain div and adds nothing to the accessibility tree. The content keeps its own semantics: give a screenshot its alt; controls in a live demo stay focusable and usable.
  • Labelled: with label the frame is a figure with that accessible name.
  • Browser bar: hidden from screen readers. Put the address in label if it matters.
  • Right-to-left: the browser dots start the bar, on the right; the address still reads left to right. A phone's camera stays in the middle.

TouchLink to "Touch"

Nothing in DeviceFrame can be pressed. Controls in a live demo bring their own hit areas.

ThemingLink to "Theming"

Tokens: --cy-device-frame-bezel, --cy-device-frame-edge, --cy-device-frame-shadow, --cy-device-frame-screen, --cy-device-frame-phone-width, --cy-device-frame-tablet-width, --cy-device-frame-browser-radius, --cy-device-frame-browser-bar and --cy-device-frame-dot.

ts
Copy
createTheme({ components: { deviceFrame: { bezel: "#3a3a3c", phoneWidth: "320px" } } });

className and style are for layout only (width, margin, placement).

AspectRatio · Image · QRCode

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog