Skip to Content

Phones

When a window counts as a phone, the compact phone scale and the keyboard.

Phone mode

PHONE_QUERY in src/lib/phone.ts decides when a window counts as a phone. That is a window at most 720px wide, or a touch screen in landscape under 500px tall. A narrow desktop window gets the same layout without touch.

In phone mode lib/phone.ts sets data-phone on the document element, and usePhone() returns true. PhoneOverride forces either answer for a subtree.

The compact phone scale

Every part takes this scale by itself on a phone. A view built from the parts doesn't need phone code.

The numbers are PHONE_SCALE in src/lib/phone.ts and the --phone-* variables in src/styles/phone.css. Change both together. Sizes are CSS pixels, the points of iOS.

WhatSize
Navigation bar44px, 36px in landscape
Tab bar50px without the home indicator, 36px in landscape
Smallest hit area44px. The visible control may be smaller
Bar button glyph, compact control30px
List row44px for one line, 58px for two
Side gutter12px
Gap between groups20px
Large title26/32, weight 700
Bar title15/20, weight 600
Body15/20
Secondary text13/18
Caption11/14, weight 500
Tab label10/12, weight 500
Text fields16/22, so Safari does not zoom in
The phone scalePHONE_SCALE and PHONE_BOUNDS in lib/phone.ts; the same numbers are the --phone-* variables. Type is drawn at its size.
Open the example ↗

Proportions

PHONE_BOUNDS holds the proportions a phone screen keeps, for browser tests to check.

  • With the keyboard closed, the navigation bar and the tab bar together take at most 12% of the height of the screen in portrait, and 20% in landscape, not counting the safe-area insets.
  • The title of a bar is no larger than the body text and no heavier than 600. A large title is at most 1.8 times the body size.
  • There is one bar at the top and one at the bottom. A second bar never stacks on either.

A phone app has a tab bar, a navigation stack for each tab, and one navigation bar for each screen. The bar has the back control, the title and at most two actions. List and root screens have large titles. A view built from ViewLayout and ViewHeader gets this with no extra code.

Stack, bar and tab barTap a row to push; the back control or a swipe from the left edge pops. Swipe a row left to archive, right to mark it read; long-press for its menu.
Open the example ↗

Sheets and lists

Sheets come from the bottom with a grab handle and rest at their detents. A short sheet rests at the height of its content, and a tall one at medium and large. Drag between them, or down to dismiss. Destructive confirmations and short choices are action sheets. Grouped inset lists hold settings and pickers.

SheetsA sheet opens at its content's height when that fits; only taller content rests at medium and large. Drag between them or down to dismiss. Destructive confirmations and short choices are action sheets.
Open the example ↗
Inset listGrouped inset lists hold settings and pickers.
Open the example ↗

The on-screen keyboard

trackViewport() follows the visual viewport and keeps --nc-keyboard, --nc-vv-height and --nc-vv-top on the document element. BottomArea stays above the keyboard. keyboardOpen() and keyboardInset() give the same facts to code.

A test that swaps in a visual viewport of its own can dispatch an nc:viewport event on window to make the module read it.

Pull to refresh and the bottom areaPull the list down; the bottom area rides above the on-screen keyboard.
Open the example ↗
Phone navigation in the gallery ↗
Edit on GitHub

Last updated on

On this page