opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Mockups
  4. Laptop
Back to Mockups

Components / Mockups

Laptop

Free Mockups React component — LaptopMockupCard. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

MacBook Pro frame wrapping your screenshot — black lid and bezel with a gray outer frame and base. Pass variant="titanium" for a titanium outer frame and base.

Preview

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/mockups/laptop-mockup-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { LaptopMockupCard } from "@/components/mockups/laptop-mockup-card";

    <LaptopMockupCard variant="titanium" />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/mockups/laptop-mockup-card.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
 
import { cn } from "@/lib/cn";
 
const laptopFrameVariants = {
gray: {
border: "border-neutral-300",
base: "bg-linear-to-b from-neutral-300 to-neutral-400",
notch: "bg-neutral-500",
},
titanium: {
border: "border-[#7a7671]",
base: "bg-linear-to-b from-[#8a8580] to-[#6a6560]",
notch: "bg-[#5c5854]",
},
} as const;
 
type LaptopFrameVariant = keyof typeof laptopFrameVariants;
 
type LaptopMockupCardProps = Readonly<
ComponentPropsWithoutRef<"div"> & {
variant?: LaptopFrameVariant;
children?: ReactNode;
}
>;
 
export const LaptopMockupCard = forwardRef<
HTMLDivElement,
LaptopMockupCardProps
>(({ className, children, variant = "gray", ...props }, ref) => {
const frame = laptopFrameVariants[variant];
 
return (
<div
ref={ref}
data-slot="laptop-mockup-card"
data-variant={variant}
className={cn("flex flex-col items-center font-sans", className)}
{...props}
>
<div
className={cn(
"w-[280px] overflow-hidden rounded-t-xl border-2 border-b-0 shadow-xl md:w-[384px]",
frame.border,
)}
>
<div className="bg-neutral-800 p-1.5 pb-0">
<div className="relative h-[184px] overflow-hidden rounded-t-[4px] bg-neutral-900 md:h-[252px]">
<div className="relative size-full overflow-hidden rounded-t-[4px]">
{children}
</div>
</div>
</div>
</div>
 
<div
className={cn(
"relative h-2.5 w-[315px] rounded-b-xl md:h-3 md:w-[432px]",
frame.base,
)}
>
<div
className={cn(
"absolute top-0 left-1/2 h-1 w-14 -translate-x-1/2 rounded-b-md md:w-16",
frame.notch,
)}
aria-hidden="true"
/>
</div>
</div>
);
});
 
LaptopMockupCard.displayName = "LaptopMockupCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/mockups/laptop-mockup-card.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.