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

Components / Mockups

Browser

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

Desktop browser chrome with traffic lights and a URL bar framing your website screenshot. Pass theme for light, dark, or transparent chrome.

Preview

opensourceui.in/components

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/browser-mockup-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { BrowserMockupCard } from "@/components/mockups/browser-mockup-card";

    <BrowserMockupCard theme="dark" url="yoursite.com/dashboard" />

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/browser-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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
 
import { cn } from "@/lib/cn";
 
const browserThemes = {
light: {
shell: "border-neutral-200",
chrome: "border-neutral-200 bg-neutral-50",
urlBar: "bg-white",
urlText: "text-neutral-400",
content: "bg-white",
},
dark: {
shell: "border-neutral-700",
chrome: "border-neutral-700 bg-neutral-800",
urlBar: "bg-neutral-900",
urlText: "text-neutral-500",
content: "bg-neutral-950",
},
transparent: {
shell: "border-neutral-300/50",
chrome: "border-neutral-300/50 bg-white/40 backdrop-blur-sm",
urlBar: "bg-white/30",
urlText: "text-neutral-500",
content: "bg-transparent",
},
} as const;
 
type BrowserTheme = keyof typeof browserThemes;
 
type BrowserMockupCardProps = Readonly<
ComponentPropsWithoutRef<"div"> & {
theme?: BrowserTheme;
url?: string;
children?: ReactNode;
}
>;
 
export const BrowserMockupCard = forwardRef<
HTMLDivElement,
BrowserMockupCardProps
>(
(
{
className,
children,
theme = "light",
url = "opensourceui.in/components",
...props
},
ref,
) => {
const styles = browserThemes[theme];
 
return (
<div
ref={ref}
data-slot="browser-mockup-card"
data-theme={theme}
className={cn(
"w-full max-w-full min-w-0 overflow-hidden rounded-xl border font-sans",
styles.shell,
className,
)}
{...props}
>
<div
className={cn(
"flex items-center gap-2 border-b px-3 py-2",
styles.chrome,
)}
>
<div className="flex gap-1.5">
<div className="h-2.5 w-2.5 rounded-full bg-red-400" />
<div className="h-2.5 w-2.5 rounded-full bg-amber-400" />
<div className="h-2.5 w-2.5 rounded-full bg-emerald-400" />
</div>
<div
className={cn(
"flex h-6 flex-1 items-center rounded-md px-2",
styles.urlBar,
)}
>
<span
className={cn("truncate font-mono text-[9px]", styles.urlText)}
>
{url}
</span>
</div>
</div>
 
<div
className={cn(
"relative h-[200px] overflow-hidden md:h-[320px]",
styles.content,
)}
>
<div className="relative size-full">{children}</div>
</div>
</div>
);
},
);
 
BrowserMockupCard.displayName = "BrowserMockupCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/mockups/browser-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.