GooseUI

Components

Device Frame

New

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 available
4 features
Details
Container queries (size)

The whole phone is sized in cqw from the width of its root, so it scales as one piece.

Your browser:
3D transforms

perspective, preserve-3d and backface-visibility build the body and its thickness from stacked layers.

Your browser:
Registered custom properties

Registered number variables let the tilt, the intro spin and the glare ease together. Without it the rotation still works but changes in steps.

Your browser:
Intersection observer

Starts the intro on the first appearance and pauses the bobbing off screen. Without it the intro is skipped.

Your browser:

Preview

Installation

npx shadcn@latest add @gooseui/device-frame
pnpm dlx shadcn@latest add @gooseui/device-frame
yarn dlx shadcn@latest add @gooseui/device-frame
bunx --bun shadcn@latest add @gooseui/device-frame

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.

A mountain landscape

Black

A mountain landscape

Titanium

A mountain landscape

Silver

A mountain landscape

Gold

A mountain landscape

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

Pro

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

First light

Clouds fill the valley before sunrise

The long way down

The long way down

A glacier valley, five hours in

Above the snow line

Above the snow line

The air gets thin and quiet

Mei Tanaka2h
<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.

A mountain landscape
<DeviceFrame
  src="/photo.webp"
  float={false}
  tilt={0}
  drag={false}
  lift={false}
  rotateX={8}
  rotateY={-24}
  rotateZ={2}
/>

Props

PropTypeDefaultDescription
childrenReactNode-Content of the screen: image, video, iframe or any component. Wins over src
srcstring-Shortcut for a picture on the screen
altstring""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
islandbooleantrueDynamic Island cut-out
bezelnumber3.4Black bezel thickness in percent of the short side of the phone
tiltnumber10Degrees the phone leans toward the mouse (mouse and pen). 0 turns it off
liftbooleantrueRises a little on hover, CSS only
floatbooleantrueSlow bobbing at rest, CSS only; paused off screen
dragbooleantrueRotate by dragging the frame, or anywhere on the screen with Alt held. Springs back on release
introbooleanfalseFades and spins in the first time the phone scrolls into view
perspectivenumber5Viewer distance in phone widths. Smaller values give a stronger 3D effect
rotateX / rotateY / rotateZnumber0Initial rotation in degrees, around each axis
scrollablebooleanfalseThe screen scrolls vertically
screenLabelstring"Device screen"Accessible name of the scrollable screen
classNamestring"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.