A phone mockup made of CSS layers, with no images, canvas or WebGL: a metal body with an edge sheen, a black bezel, a Dynamic Island, side buttons, a glass glare that follows the angle and a soft contact shadow. An image, a video, an iframe or a live component goes on the screen. The markup comes from the server; bobbing, the hover lift and the intro are plain CSS, and a small client island only writes the pointer rotation into CSS variables.
Browser Support
Baseline Newly available4 featuresDetails
The whole phone is sized in cqw from the width of its root, so it scales as one piece.
perspective, preserve-3d and backface-visibility build the body and its thickness from stacked layers.
Registered number variables let the tilt, the intro spin and the glare ease together. Without it the rotation still works but changes in steps.
Starts the intro on the first appearance and pauses the bobbing off screen. Without it the intro is skipped.
Preview
Installation
Usage
import { DeviceFrame } from "@/components/ui/device-frame"
export default function Example() {
return (
<DeviceFrame className="w-60" finish="titanium">
<video
src="/story.mp4"
autoPlay
muted
loop
playsInline
className="size-full object-cover"
/>
</DeviceFrame>
)
}
// A plain picture
<DeviceFrame src="/screenshot.webp" alt="Dashboard on a phone" />Examples
Finishes
finish is "black", "titanium", "silver", "gold" or "blue". These are decorative palettes; override one color with --device-frame in style.

Black

Titanium

Silver

Gold

Blue
<DeviceFrame finish="gold" src="/photo.webp" />
{/* "black" | "titanium" | "silver" | "gold" | "blue" */}
<DeviceFrame
src="/photo.webp"
style={{ "--device-frame": "oklch(0.55 0.2 20)" } as React.CSSProperties}
/>Landscape with video
orientation="landscape" turns the body, not the content: the screen changes its proportions and the picture stays upright. The width you set is the long side.
<DeviceFrame orientation="landscape" className="w-80">
<video src="/story.mp4" autoPlay muted loop playsInline className="size-full object-cover" />
</DeviceFrame>Scrollable screen
scrollable makes the screen scroll natively with the wheel, touch and keys. Switches and buttons inside work as usual, and dragging never takes over the content.
Mei Tanaka
Trail photographer
Settings




<DeviceFrame scrollable screenLabel="Profile screen" className="w-64">
<div className="min-h-full bg-background px-4 pt-14 pb-6">
{/* long content: pt-14 keeps it clear of the island */}
</div>
</DeviceFrame>A live component inside
Anything fits on the screen, here a StoryPlayer. Give it size-full and no radius so it fills the glass.

First light
Clouds fill the valley before sunrise

The long way down
A glacier valley, five hours in

Above the snow line
The air gets thin and quiet
<DeviceFrame finish="blue">
<StoryPlayer
slides={slides}
author="Mei Tanaka"
className="size-full max-w-none rounded-none"
/>
</DeviceFrame>Static
Turn the motion off and set the angle yourself: the phone is just a still mockup.

<DeviceFrame
src="/photo.webp"
float={false}
tilt={0}
drag={false}
lift={false}
rotateX={8}
rotateY={-24}
rotateZ={2}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | - | Content of the screen: image, video, iframe or any component. Wins over src |
| src | string | - | Shortcut for a picture on the screen |
| alt | string | "" | Alt text of the src picture. Empty means decorative |
| finish | "black" | "titanium" | "silver" | "gold" | "blue" | "black" | Body palette |
| orientation | "portrait" | "landscape" | "portrait" | The body rotates; the content stays upright and gets the new proportions |
| island | boolean | true | Dynamic Island cut-out |
| bezel | number | 3.4 | Black bezel thickness in percent of the short side of the phone |
| tilt | number | 10 | Degrees the phone leans toward the mouse (mouse and pen). 0 turns it off |
| lift | boolean | true | Rises a little on hover, CSS only |
| float | boolean | true | Slow bobbing at rest, CSS only; paused off screen |
| drag | boolean | true | Rotate by dragging the frame, or anywhere on the screen with Alt held. Springs back on release |
| intro | boolean | false | Fades and spins in the first time the phone scrolls into view |
| perspective | number | 5 | Viewer distance in phone widths. Smaller values give a stronger 3D effect |
| rotateX / rotateY / rotateZ | number | 0 | Initial rotation in degrees, around each axis |
| scrollable | boolean | false | The screen scrolls vertically |
| screenLabel | string | "Device screen" | Accessible name of the scrollable screen |
| className | string | "w-60" | Extra classes. Set the width here (w-60 by default): that is the short side in portrait, the long side in landscape |
CSS variables
Override them through style. --device-frame is the body color (the light and dark tones of the edge are derived from it), --device-bezel-color is the bezel, --device-screen is the color behind the content (black by default), --device-shadow is the contact shadow.
Interaction
- Tilt: the phone leans toward a mouse or pen over it. Touch does not tilt.
- Lift: on hover the phone rises and the shadow shrinks, in CSS with :hover.
- Drag: press and drag the metal rim or the black bezel. Over the screen it works only with Alt held, because the screen belongs to its content: scrolling, clicks, links and video controls are never intercepted. With src (a plain picture) the whole screen drags.
- A press that does not move 4 px stays a normal click. After a real drag the click is swallowed.
- The wheel is never intercepted.
Accessibility
- The body, bezel, island, glare, buttons and shadow are aria-hidden. The content on the screen stays in the accessibility tree.
- With src the picture is a normal img: pass alt, or leave it empty for a decorative one.
- A scrollable screen is a labeled region that Tab can focus, so the keyboard scrolls it.
- prefers-reduced-motion: reduce stops the bobbing, the lift, the tilt, the drag and the intro; the phone is still, at its initial angle.
- Dragging is pointer-only decoration; nothing in the content depends on it.
Notes
- The screen is a size container (container-type: inline-size), so content can size itself with cqw units against the glass.
- The thickness is eight stacked layers. At large angles the side can look slightly stepped, so dragging is limited to 75° around Y and 45° around X.
- With intro the phone is hidden until it first scrolls into view. Without JavaScript it is shown right away.
- Colors of the body are CSS variables; overriding them with a Tailwind class does not work, use the style prop.