Skip to content
Qiyang.Dev

iPhone Preview

This component displays an app screenshot inside an iPhone frame. You can add clickable areas to switch between screens. Try the Home and Settings tabs below.

Home screen on iOS

Usage

<IPhonePreview initialScreenshot={home} alt="Home screen" />

<IPhonePreview
  model="iPhoneDuo"
  initialScreenshot={duoScreenshot}
  alt="App on iPhone Duo"
/>

Supported models are iPhone18ProMax (the default, Burgundy) and iPhoneDuo (Night Sky, inner screen open in portrait). Each model uses its own frame, screen mask, screen bounds, and display width. Use a screenshot matching the selected screen’s aspect ratio to avoid cropping; screenshots fill the screen with object-fit: cover.

Props

PropTypeRequiredDescription
model"iPhone18ProMax" | "iPhoneDuo"NoDevice frame to display. Defaults to "iPhone18ProMax".
initialScreenshotImageMetadataYesThe first screenshot to display.
altstringYesAlternative text for the first screenshot.
loading"eager" | "lazy"NoImage loading strategy. Defaults to "lazy"; use "eager" for a preview visible on initial load.
hotspotsHotspot[]NoClickable areas that switch between screenshots. Defaults to an empty array.

Hotspot

Positions and sizes are percentages of the screen bounds. For example, x: 50 starts halfway across the screen.

FieldTypeRequiredDescription
xnumberYesDistance from the left edge of the screen.
ynumberYesDistance from the top edge of the screen.
widthnumberYesWidth of the clickable area.
heightnumberYesHeight of the clickable area.
labelstringYesAccessible name for the button.
toImageMetadataYesScreenshot to display after clicking.
altstringYesAlternative text for the target screenshot.
fromImageMetadataNoScreenshot on which the area is active. Defaults to initialScreenshot.

Adding a model

Generate a screen mask and bounds from a transparent bezel image:

node scripts/bezel-mask.mjs path/to/bezel.png path/to/bezel-mask.png

The script creates a mask and a JSON file with the screen bounds. The image must have a closed transparent screen area containing its center. Add the bezel, mask, and bounds to src/utils/iphonePreviewModels.ts, along with a maxWidth (CSS display width) and imageWidth (generated image width in pixels). The model prop automatically accepts the new configuration key. Hotspot coordinates remain relative to the selected model’s screen bounds.