MacBook
loomui/macbookFreeComponent
A laptop frame with the camera housing cut into the display and the scoop cut into its base.
Live preview
live · rendered by the registry
Rendered by loomui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://loomui.design/r/macbook.jsonSource
1import * as React from "react"23import { cn } from "@/lib/utils"45export interface MacBookProps extends React.ComponentProps<"div"> {6 /** Largest width the machine is drawn at, in pixels. It shrinks below this. */7 width?: number8 /** Screenshot to fill the screen with. */9 src?: string10 /** Description of the screenshot. Required whenever `src` is set. */11 alt?: string12 /** Draw the camera housing cut into the top of the display. */13 notch?: boolean14 /** Draw the base the lid stands on. */15 base?: boolean16}1718/**19 * MacBook Pro 14" in points. The base is a little wider than the lid, which is20 * the only reason the machine reads as standing on something rather than21 * floating above a bar.22 */23const LID_WIDTH = 154424const LID_HEIGHT = 101425const BASE_WIDTH = 160026const BASE_HEIGHT = 262728export function MacBook({29 children,30 src,31 alt = "",32 width = 620,33 notch = true,34 base = true,35 className,36 style,37 ...props38}: MacBookProps) {39 const height = LID_HEIGHT + (base ? BASE_HEIGHT : 0)4041 // Shares of the whole machine's width, so the lid, the base and the scoop42 // stay in step with each other at any size.43 const cq = (points: number) =>44 `${((points / BASE_WIDTH) * 100).toFixed(4)}cqw`4546 return (47 <div48 data-slot="macbook"49 className={cn("relative w-full", className)}50 style={{51 maxWidth: width,52 aspectRatio: `${BASE_WIDTH} / ${height}`,53 containerType: "inline-size",54 ...style,55 }}56 {...props}57 >58 {/* The lid. Narrower than the base and centred on it. */}59 <div60 className="mx-auto bg-linear-to-br from-neutral-500 via-neutral-700 to-neutral-600 shadow-xl"61 style={{62 width: cq(LID_WIDTH),63 height: cq(LID_HEIGHT),64 borderRadius: cq(22),65 padding: cq(16),66 }}67 >68 <div69 className="relative h-full w-full overflow-hidden bg-neutral-200 dark:bg-neutral-800"70 style={{ borderRadius: cq(8) }}71 >72 {src ? (73 <img src={src} alt={alt} className="h-full w-full object-cover" />74 ) : (75 children76 )}7778 {/* The camera housing is bezel that intrudes into the display, so it79 is drawn over the screen rather than around it. */}80 {notch ? (81 <span82 aria-hidden="true"83 className="absolute top-0 left-1/2 -translate-x-1/2 bg-neutral-900"84 style={{85// … truncated
What it pulls in
Other registry items
Files it writes
More from loomui
All 91 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Aurora Backdropaurora-backdrop | loomui | Components | Free | no deps | |
| Bento Gridbento-grid | loomui | Components | Free | no deps | |
| Card Stackcard-stack | loomui | Components | Free | no deps | |
| Compare Slidercompare-slider | loomui | Components | Free | no deps | |
| Confetti Buttonconfetti-button | loomui | Components | Free | no deps | |
| Count Upcount-up | loomui | Components | Free | no deps | |
| Credit Cardcredit-card | loomui | Components | Free | no deps | |
| Drawerdrawer | loomui | Components | Free | 1 dep |
