Phone
An iPhone drawn to scale, for showing a mobile screen built from real components.
Usage
import { Phone, PhoneContent, PhoneStatusBar } from 'nyctoui/phone'
<Phone sx={styles.phone}>
<PhoneStatusBar />
<PhoneContent>…</PhoneContent>
</Phone>The proportions are the 6.3″ iPhone 17 Pro’s. The screen is 402 × 874 points, Apple’s figure, and children lay out on it at one CSS pixel per point, as a page does in Safari on the phone. The body is Apple’s 71.9 × 150 mm at 460 ppi, which leaves a 16-point border all round. The screen corners, the Dynamic Island and the home indicator use community measurements of the same panel.
Only the proportions are the hardware’s. The frame is a card surface, the same fill, ring and lift as Panel, so the phone sits on a page of components as one of them.
The phone draws at life size, 434 points wide, and never wider than its parent. Give it a width with sx and the whole device scales to match, content included, so a 320px phone shows exactly what a 402-point screen would.
PhoneStatusBar floats over the top of the screen and PhoneContent scrolls under it, padded by the 62-point top and 34-point bottom safe areas. Pin your own bars with absolute positioning and the device.safeBottom token, as the demo does with its button.
Good for
- A landing page showing a mobile app built from real components.
- Docs or a design review showing how a screen looks on a phone.
- A preview of a mobile email or a push notification in a marketing tool.
- An onboarding tour that walks through a mobile flow step by step.
Examples
Appearance
appearance sets the screen’s color-scheme, so every token inside switches theme while the page stays as it is. Leave it out to follow the page. The frame follows the page either way.
With a keyboard
The phone Keyboard docked to the bottom edge, padded by the safe area as the system keyboard is. It types into the field above.
Composing on the screen
Tap the composer and a field rises with the keyboard, docked to the bottom of the screen; return adds the to-do and Escape or Cancel puts it away. It is drawn on the screen itself. A Drawer or Dialog can’t be kept inside the phone: ui-sdk opens popups in the browser’s top layer, which covers the whole window whatever their container.
Accessibility
The frame, island, status bar and home indicator are hidden from assistive technology, since none of them do anything. Only what you put on the screen is read out and reachable by keyboard.
Best practices
- Build the screen from real components, so the preview stays true as they change.
- Size it with
sxwhen it needs to be smaller; everything inside scales with it. - Leave room for the status bar and the home indicator, as a real app would.
- Use it to frame a screenshot. Put a real image in an image element instead.
- Put content people must use inside it. It’s a picture of a phone, not a place to do work.
API reference
Phone
The device. Renders a <div>; children go on the screen.
| Prop | Type | Default |
|---|---|---|
appearanceTheme of the screen. Follows the page when left out. | 'light' | 'dark' | — |
screenRefRef to the screen, for measuring it or placing UI of your own on it. Popups such as Drawer open over the whole window and are not confined by it. | Ref<HTMLDivElement> | — |
sxStyleX styles merged after the built-in ones. Set width here to scale the phone. | StyleXStyles | — |
PhoneStatusBar
Clock, signal, Wi-Fi and battery beside the island. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
timeThe clock text. | string | '9:41' |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
PhoneContent
Full-screen scroller padded by the safe areas. Renders a <div>.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |