Device frame
A browser window or phone frame around any content, with a soft layered shadow.
Preview
The frame tilts in 3D toward a mouse pointer, a soft highlight follows the pointer and the glow behind shifts the other way; on leave it springs back flat with a little overshoot. There is no tilt on touch screens or for keyboard users, who lose nothing. With reduced motion turned on, it renders the plain layout.
example.com/stats
Weekly active usersSample data
Signups (sample data)
example.com/stats
Weekly active usersSample data
Signups (sample data)
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { DeviceFrame } from "@/components/custom/device-frame";
<DeviceFrame device="browser" url="yourproduct.com">
<img src={screenshotUrl} alt="The dashboard" />
</DeviceFrame>
<DeviceFrame device="phone">
<img src={mobileUrl} alt="The mobile app" />
</DeviceFrame>import { DeviceFrameMotion } from "@/components/custom/device-frame/device-frame-motion";
<DeviceFrameMotion device="phone">{children}</DeviceFrameMotion>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| device | "browser" | "phone" | "browser" | Which frame to draw. |
| url | string | – | Text in the browser's address bar. Ignored for the phone. |
| children* (required) | ReactNode | – | What the device shows: an image, a video or a live component. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| device | "browser" | "phone" | "browser" | Which frame to draw. |
| url | string | – | Text in the browser's address bar. Ignored for the phone. |
| children* (required) | ReactNode | – | What the device shows: an image, a video or a live component. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute (id, aria-*, data-*, ref) goes to the root element. |
Accessibility
- The frame is decoration; give the content its own text alternative.
- Content inside stays interactive: links and buttons in a live component still work.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.