iPad
loomui/ipadFreeComponent
A tablet frame drawn from the real measurements, upright or on its side, with a screen you put anything in.
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/ipad.jsonSource
1import * as React from "react"23import { cn } from "@/lib/utils"45export interface IPadProps extends React.ComponentProps<"div"> {6 /** Largest width the device 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 /** Which way up the tablet is held. */13 orientation?: "portrait" | "landscape"14 /** Draw the camera in the bezel above the screen. */15 camera?: boolean16}1718/** iPad Pro 11" in points, held upright. */19const SHORT_SIDE = 83420const LONG_SIDE = 11942122export function IPad({23 children,24 src,25 alt = "",26 width = 420,27 orientation = "portrait",28 camera = true,29 className,30 style,31 ...props32}: IPadProps) {33 const portrait = orientation === "portrait"34 const deviceWidth = portrait ? SHORT_SIDE : LONG_SIDE35 const deviceHeight = portrait ? LONG_SIDE : SHORT_SIDE3637 // Every measurement is a share of the frame's own width, so the proportions38 // hold at whatever size the frame ends up rather than at one tuned by eye.39 const cq = (points: number) =>40 `${((points / deviceWidth) * 100).toFixed(4)}cqw`4142 return (43 <div44 data-slot="ipad"45 className={cn("relative w-full", className)}46 style={{47 maxWidth: width,48 aspectRatio: `${deviceWidth} / ${deviceHeight}`,49 containerType: "inline-size",50 ...style,51 }}52 {...props}53 >54 <div55 className="absolute inset-0 bg-linear-to-br from-neutral-500 via-neutral-700 to-neutral-600 shadow-xl"56 style={{ borderRadius: cq(50), padding: cq(22) }}57 >58 <div59 className="relative h-full w-full overflow-hidden bg-neutral-200 dark:bg-neutral-800"60 style={{ borderRadius: cq(32) }}61 >62 {src ? (63 <img src={src} alt={alt} className="h-full w-full object-cover" />64 ) : (65 children66 )}67 </div>6869 {/* In the bezel rather than on the screen, which is where it sits and70 what keeps it out of anything laid over the display. */}71 {camera ? (72 <span73 aria-hidden="true"74 className="absolute left-1/2 -translate-x-1/2 rounded-full bg-neutral-900"75 style={{ top: cq(8), width: cq(7), height: cq(7) }}76 />77 ) : null}78 </div>79 </div>80 )81}
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 |
