Effects
Glass Laptop
A CSS 3D laptop mockup whose lid opens onto your screenshot or React screen.
pnpm dlx shadcn@4.14.1 add @glassyui/glass-laptopPreview
Demos ready. Update 0.
Installation
First add the exact @glassyui mapping to components.json as shown in Getting Started. Then run the pinned item command:
pnpm dlx shadcn@4.14.1 add @glassyui/glass-laptopWhat this installs2 files, 1 package
Direct registry declarations
These values belong to @glassyui/glass-laptop itself in registry.json.
Package dependencies
clsx
Registry dependencies
None declared.
File targets
components/glassyui/glass-laptop.tsxcomponents/glassyui/styles/laptop.css
Complete installed closure
This follows every namespaced registry dependency recursively and de-duplicates the packages and target files installed with this item.
Package dependencies
clsx
Installed files
components/glassyui/glass-laptop.tsxcomponents/glassyui/styles/laptop.css
Usage
import { GlassLaptop } from "@/components/glassyui/glass-laptop";
export function Showcase() {
return (
<GlassLaptop
aria-label="The app on a laptop"
className="w-full max-w-5xl"
>
<img alt="" className="size-full object-cover" src="/app.png" />
</GlassLaptop>
);
}Examples
const [open, setOpen] = useState(false);
useEffect(() => {
const frame = requestAnimationFrame(() => setOpen(true));
return () => cancelAnimationFrame(frame);
}, []);
return (
<GlassLaptop open={open} finish="silver">
<YourScreen />
</GlassLaptop>
);API
GlassLaptopForward-ref figure drawing the laptop. Its children fill the screen.
childrenScreen content, laid out at the resolution below and scaled to fit. It renders only while the screen is lit.
openWhether the lid is up. Changing it opens or closes the lid. Defaults to true.
finishblack or silver. Defaults to black.
resolutionWidth in CSS pixels the screen lays its content out at, like the display’s "looks like" setting. Defaults to 1728, the 16-inch default.
glareA faint reflection across the glass. Defaults to true.
Notes
Rendering
The laptop mockup is modeled on the proportions of a 16-inch MacBook Pro laptop, with a notched screen, keyboard and trackpad. It uses CSS 3D with no images or WebGL. Open, the lid faces you; shut, the view rises to show the closed case from above, and it moves back down as the lid opens.
Screen
The screen lights once the lid and the view have come to rest, and goes dark before the lid closes. Menus and dialogs that the content opens in a portal appear on the page at full size, so a screen meant to be looked at can be marked inert.
Accessibility
Reduced motion opens and closes the lid at once, and reduced transparency takes the reflection off the glass. Give the figure an aria-label that says what the screen shows.
Trademarks
MacBook Pro is a trademark of Apple Inc., registered in the U.S. and other countries and regions. Glass Laptop is an independent component and has not been authorized, sponsored or otherwise approved by Apple Inc.
Accessibility
Keep the Radix-backed semantics intact and preserve visible labels, focus states, and keyboard operation when copying the source.
Performance
Use provider quality preferences for dense app screens. Reserve strong refraction for hero or showcase surfaces.