Browse docsGetting Started

Guide

Build a laptop mockup in React

Use Glass Laptop for a CSS 3D React mockup. Add a screenshot or live screen, animate the lid, and choose black or silver.

A laptop drawn in CSS, not a photo

Glass Laptop is a free, MIT-licensed React component. CSS 3D draws its notched screen, keyboard and trackpad, with no images or WebGL. Your screenshot or live React content fills the screen.

Shut, the view looks down on the closed case. Open, the lid faces you. Changing its open prop swings the lid and moves the view between the two, and the screen lights once both have come to rest.

Install it

Run this command in a Tailwind CSS 4 app initialized for shadcn. It brings its own stylesheet and needs only clsx. The installation guide covers the app setup.

Install Glass Laptop

npx shadcn@4.14.1 add @glassyui/glass-laptop

Put a screenshot on the screen

The screen has a 3456 by 2234 aspect ratio. An image with that ratio fills it exactly. Any 16:10 image works too: object-cover trims a sliver from its sides.

A screenshot on the screen

import { GlassLaptop } from "@/components/glassyui/glass-laptop";

export function AppShowcase() {
  return (
    <GlassLaptop aria-label="The app’s dashboard on a laptop" className="w-full max-w-5xl">
      <img alt="" className="size-full object-cover" src="/dashboard.png" />
    </GlassLaptop>
  );
}

Or put a live React screen on it

Children are laid out at resolution CSS pixels wide, 1728 by default, and scaled to fit. Pass a smaller width, such as 1496, to show larger text.

The children render only while the screen is lit. Menus and dialogs they open in a portal appear on the page at full size, so mark a screen that is only for show inert.

A live screen

<GlassLaptop aria-label="The editor on a laptop" resolution={1496}>
  <div className="size-full" inert>
    <Editor />
  </div>
</GlassLaptop>

Open the lid as the page loads

Start shut and open it on the next frame, so the closed case paints first and the lid swings up while the view moves in. Reduced motion skips the movement.

Open on load

const [open, setOpen] = useState(false);

useEffect(() => {
  const frame = requestAnimationFrame(() => setOpen(true));

  return () => cancelAnimationFrame(frame);
}, []);

return (
  <GlassLaptop open={open} finish="silver">
    <YourScreen />
  </GlassLaptop>
);

Choose a finish and a look

finish is black or silver. A faint reflection crosses the glass by default; pass glare={false} for flat marketing captures. Give the laptop an aria-label that says what its screen shows.

Do I get a laptop mockup image or a React component?

Glass Laptop is a React component for websites. It does not export images. You can put an existing screenshot on its screen or render a live React view. The installation copies the source into your project, so you can change the frame and animation yourself.