Browser Window
The BrowserWindow component is a sleek and customizable React UI component that mimics a browser window, perfect for showcasing website previews, code snippets, or application demos. Designed with Tailwind CSS, it features a modern dark-themed UI, a decorative URL bar, and traffic light buttons for an authentic look.
Preview
stackbits.dev
All this, just one Ctrl+C, Ctrl+V away. 😉
Follow below steps 👇🏻
Component
Create a file browser-window.tsx in your components folder and paste this code
1import React from 'react';23type BrowserWindowProps = {4children: React.ReactNode;5url?: string;6className?: string;7childrenClassName?: string;8ref?: React.RefObject<HTMLDivElement | null>;9} & React.HTMLAttributes<HTMLDivElement>;1011const BrowserWindow: React.FC<BrowserWindowProps> = ({12children,13url,14className,15childrenClassName,16ref,17...props18}) => {19return (20<div21ref={ref}22className={`flex flex-col items-center justify-between rounded-lg overflow-hidden border border-neutral-700 shadow-lg bg-neutral-900/60 h-full w-full relative ${className}`}23style={{ minWidth: '150px', minHeight: '200px' }}24{...props}25>26{/* Browser Header */}27<div className="flex items-center px-4 py-2 bg-neutral-800 border-b border-neutral-700 w-full">28{/* Traffic Light Buttons */}29<div className="flex space-x-2">30<div className="w-3 h-3 rounded-full bg-red-500" />31<div className="w-3 h-3 rounded-full bg-yellow-500" />32<div className="w-3 h-3 rounded-full bg-green-500" />33</div>3435{/* URL Bar (optional, for decoration) */}36<div className="flex-1 mx-4">37<div className="h-6 bg-neutral-600 rounded-md w-full flex items-center justify-center">38<p className="text-xs text-neutral-300">{url}</p>39</div>40</div>41</div>4243{/* Browser Content */}44<div className={`w-full flex-1 p-2 flex items-center justify-center ${childrenClassName}`}>45{children}46</div>47</div>48);49};5051export default BrowserWindow;
Usage
1<BrowserWindow url="stackbits.dev" childrenClassName="py-20">2<div>This is a browser window.</div>3</BrowserWindow>
⭐️ Got a question or feedback?
Feel free to reach out!