Synertech Web/ui v0.57.5 Site Storybook

Documentation / Advanced

DeviceMockup

Client@synertech/uiOpen in Storybook

A device frame drawn in CSS to showcase a screenshot or a real interface: iPhone (phone), android, tablet, laptop, desktop, watch (watch) or browser window (browser). Every device comes in three sizes, in a light or dark theme, and accepts a custom frame colour.

The screen shows either an image (src + alt) or your React children: a real component stays interactive in it. orientation="landscape" swaps width and height (no effect on the watch and the browser), showStatusBar simulates the status bar of phones and tablets, and animated scrolls the content in a loop at scrollSpeed pixels per second, handy for a landing page. A "use client" component.

Examples

Screenshot on a phone

src and alt show an image on the screen; showStatusBar adds the time and the indicators.

Open in a tab
import { DeviceMockup } from "@synertech/ui";

export function Phone() {
  return (
    <DeviceMockup
      device="phone"
      src="https://picsum.photos/480/960"
      alt="Écran d’accueil de l’application"
      showStatusBar
      statusBarTime="9:41"
    />
  );
}

The devices

The same content in several frames, at a small size.

Open in a tab
import { DeviceMockup } from "@synertech/ui";

export function Devices() {
  return (
    <div className="flex flex-wrap items-end gap-6">
      <DeviceMockup
        device="android"
        size="sm"
        src="https://picsum.photos/360/640"
        alt="Application Android"
      />
      <DeviceMockup
        device="tablet"
        size="sm"
        src="https://picsum.photos/640/840"
        alt="Application tablette"
      />
      <DeviceMockup
        device="laptop"
        size="sm"
        src="https://picsum.photos/800/500"
        alt="Tableau de bord"
      />
      <DeviceMockup
        device="watch"
        size="sm"
        src="https://picsum.photos/160/192"
        alt="Cadran de la montre"
      />
    </div>
  );
}

Interactive React content

The children replace the image: here a mini interface in a browser window.

Open in a tab
import { DeviceMockup } from "@synertech/ui";

export function ReactContent() {
  return (
    <DeviceMockup device="browser" theme="light" contentClassName="bg-white">
      <div className="space-y-3 p-6">
        <h3 className="text-lg font-semibold">Tableau de bord</h3>
        <div className="grid grid-cols-3 gap-3">
          {["Ventes", "Visites", "Paniers"].map((label) => (
            <div key={label} className="rounded-md border border-gray-200 p-3 text-sm">
              {label}
            </div>
          ))}
        </div>
        <button type="button" className="rounded-md bg-blue-600 px-3 py-1.5 text-sm text-white">
          Exporter
        </button>
      </div>
    </DeviceMockup>
  );
}

Orientation, theme and colour

orientation="landscape" lays the device on its side; theme and frameColor dress the frame.

Open in a tab
import { DeviceMockup } from "@synertech/ui";

export function Appearance() {
  return (
    <div className="flex flex-wrap items-center gap-6">
      <DeviceMockup
        device="phone"
        orientation="landscape"
        theme="light"
        size="sm"
        src="https://picsum.photos/640/360"
        alt="Vidéo en plein écran"
      />
      <DeviceMockup
        device="tablet"
        size="sm"
        frameColor="#1e3a8a"
        src="https://picsum.photos/640/840"
        alt="Liseuse"
      />
    </div>
  );
}

Auto-scroll

animated scrolls a long screenshot in a loop; scrollSpeed sets the speed in pixels per second.

Open in a tab
import { DeviceMockup } from "@synertech/ui";

export function AutoScroll() {
  return (
    <DeviceMockup
      device="desktop"
      size="lg"
      animated
      scrollSpeed={60}
      src="https://picsum.photos/1440/4000"
      alt="Page d’accueil complète du site"
    />
  );
}

API reference

Components

DeviceMockup

ComponentClient
import { DeviceMockup } from "@synertech/ui";

Props — DeviceMockupProps

PropTypeDefaultDescription
alt string —

Alt text for the image

animated boolean false

Scroll the content slowly from top to bottom, then start again. Off when the reader asked for reduced motion

children ReactNode —

React content to display inside the device screen

className string —

Additional class names for the wrapper

contentClassName string —

Additional class names for the screen/content area

device DeviceType "phone"

Device type to render

frameColor string —

Frame color override (CSS color value)

orientation DeviceOrientation "portrait"

Device orientation. A phone, an android and a tablet turn; a laptop, a desktop, a watch and a browser keep their own shape

scrollSpeed number 30

Scroll animation speed in pixels per second

showStatusBar boolean false

Show simulated status bar (phone, android, tablet)

size DeviceSize "md"

Device size

src string —

Image source to display inside the device screen

statusBarTime string —

Time displayed in the status bar

theme DeviceTheme "dark"

Device frame theme

Types

type DeviceOrientation = "portrait" | "landscape"
type DeviceSize = "sm" | "md" | "lg"
type DeviceTheme = "light" | "dark"
type DeviceType = | "phone"
  | "android"
  | "tablet"
  | "laptop"
  | "desktop"
  | "watch"
  | "browser"