# Touch & mobile

Hit areas and room between targets from the components, content clear of the notch and the on-screen keyboard, and no gesture as the only way.

API [Button](/ui/storybook/?path=/docs/ui-primitives-button--docs) [Checkbox](/ui/storybook/?path=/docs/ui-primitives-checkbox--docs) [DropdownMenu](/ui/storybook/?path=/docs/ui-primitives-dropdownmenu--docs) [HighlightedInput](/ui/storybook/?path=/docs/ui-primitives-highlightedinput--docs) [Input](/ui/storybook/?path=/docs/ui-primitives-input--docs) [RadioGroup](/ui/storybook/?path=/docs/ui-primitives-radiogroup--docs) [Select](/ui/storybook/?path=/docs/ui-primitives-select--docs) [Switch](/ui/storybook/?path=/docs/ui-primitives-switch--docs) [Tabs](/ui/storybook/?path=/docs/ui-primitives-tabs--docs) [Textarea](/ui/storybook/?path=/docs/ui-primitives-textarea--docs) [Toolbar](/ui/storybook/?path=/docs/ui-toolbar--docs) [Toggle](/ui/storybook/?path=/docs/ui-primitives-toggle--docs) [SegmentedControl](/ui/storybook/?path=/docs/ui-primitives-segmentedcontrol--docs) [InfoPopover](/ui/storybook/?path=/docs/ui-primitives-infopopover--docs) [List](/ui/storybook/?path=/docs/ui-primitives-list--docs) [Table](/ui/storybook/?path=/docs/ui-primitives-table--docs) [FilterMenu](/ui/storybook/?path=/docs/ui-filtermenu--docs) [QueryBox](/ui/storybook/?path=/docs/ui-querybox--docs) [Reorder](/ui/storybook/?path=/docs/ui-reorder--docs) [Sheet](/ui/storybook/?path=/docs/ui-primitives-sheet--docs) [Toaster](/ui/storybook/?path=/docs/ui-primitives-toaster--docs) [useVisualViewportInsets](/ui/storybook/?path=/docs/ui-hooks-usevisualviewportinsets--docs) [useScrollInsets](/ui/storybook/?path=/docs/ui-hooks-usescrollinsets--docs) [useAutoHideHeader](/ui/storybook/?path=/docs/ui-hooks-useautohideheader--docs) [useMediaQuery](/ui/storybook/?path=/docs/ui-hooks-usemediaquery--docs) [MarkdownEditor](/ui/storybook/?path=/docs/ui-codemirror-markdowneditor--docs)

**On a coarse pointer every part looks as it does under a mouse, and the components give each control a 36px hit area and keep neighbouring targets 36px apart by themselves; the app keeps its own controls to the same rule, its edges clear of the notch and the keyboard, and every gesture backed by something to tap.**

```tsx
import { INBOX_PEOPLE, INBOX_THREADS } from "@orz/fixtures/inbox.ts";
import { Button } from "@orz/ui/components/button";
import { Checkbox } from "@orz/ui/components/checkbox";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@orz/ui/components/dropdown-menu";
import { EmptyState } from "@orz/ui/components/empty-state";
import { List, ListItem } from "@orz/ui/components/list";
import {
  ArchiveIcon,
  EllipsisIcon,
  MailIcon,
  SquarePenIcon,
  Trash2Icon,
} from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";

const THREADS = INBOX_THREADS.filter(({ folder }) => folder === undefined)
  .slice(0, 3)
  .map(({ id, subject, messages }) => ({
    id,
    subject,
    from: INBOX_PEOPLE[messages[0]?.from ?? ""],
  }));

type Thread = (typeof THREADS)[number];

export function MailList() {
  const [threads, setThreads] = useState(THREADS);
  const remove = (thread: Thread, message: string) => {
    setThreads((now) => now.filter((each) => each !== thread));
    toast(message, {
      action: {
        label: "Undo",
        onClick: () =>
          setThreads((now) =>
            THREADS.filter((each) => each === thread || now.includes(each)),
          ),
      },
    });
  };
  return (
    <div className="grid gap-3">
      <List purpose="collection">
        <ul>
          {threads.map((thread) => (
            <ListItem key={thread.id} asChild>
              <li className="flex min-h-row items-center gap-3 px-3 py-2">
                <Checkbox aria-label={`Select “${thread.subject}”`} />
                <div className="grid min-w-0 flex-1 text-ui">
                  <span className="truncate font-medium">{thread.from}</span>
                  <span className="truncate text-muted-foreground">
                    {thread.subject}
                  </span>
                </div>
                <DropdownMenu>
                  <DropdownMenuTrigger asChild>
                    <Button
                      variant="ghost"
                      size="icon-xs"
                      aria-label={`More actions for “${thread.subject}”`}
                    >
                      <EllipsisIcon />
                    </Button>
                  </DropdownMenuTrigger>
                  <DropdownMenuContent align="end" className="w-48">
                    <DropdownMenuItem
                      onSelect={() => remove(thread, "Conversation archived")}
                    >
                      <ArchiveIcon />
                      Archive
                    </DropdownMenuItem>
                    <DropdownMenuItem
                      onSelect={() =>
                        remove(thread, "Conversation moved to Trash")
                      }
                    >
                      <Trash2Icon />
                      Delete
                    </DropdownMenuItem>
                    <DropdownMenuItem
                      onSelect={() => toast("Conversation marked as unread")}
                    >
                      <MailIcon />
                      Mark as unread
                    </DropdownMenuItem>
                  </DropdownMenuContent>
                </DropdownMenu>
              </li>
            </ListItem>
          ))}
          {threads.length === 0 && (
            <li>
              <EmptyState title="Nothing in Inbox" className="py-6" />
            </li>
          )}
        </ul>
      </List>
      <Button size="lg" className="justify-self-end">
        <SquarePenIcon />
        Compose
      </Button>
    </div>
  );
}
```

On a phone this is already the touch layout; on a desk, press **Touch** above the example. Nothing is drawn larger: the checkboxes, the `⋯` buttons and **Compose** keep their size and take a 36px hit area around it, and the rows of each `⋯` menu are 36px tall. The conversations' rows are taller than that already, so they do not grow at all. On a phone each `⋯` menu also rises from the bottom edge as a sheet the whole width, titled with what it acts on, in reach of the thumb and clear of the keyboard; [Overlays](/ui/guidelines/patterns/overlays/index.md#touch) has the details. **Touch** alone keeps the desk's width, and the menu beside its button.

## Hit areas

Apple gives a control on iOS 44 × 44pt by default and 28 × 28pt at the least, and counts the space between controls as much as their size ([Apple HIG: Accessibility](https://developer.apple.com/design/human-interface-guidelines/accessibility)); WCAG asks for 24px ([2.5.8](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html), AA) and 44px ([2.5.5](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html), AAA). @orz/ui takes 36px on a coarse pointer, through its `touch:` variant, and spends it on what keeps a finger on the right target rather than on drawing a dense screen larger:

- Every control keeps the size its style draws it at, and takes a transparent `::after` 36px square, centred on it, as its hit area.
- Neighbouring targets stand 36px apart, centre to centre, so no two hit areas overlap.
- Only what has no other way to make that room changes size: a row a finger taps, a strip of small controls along the edge of a box that clips, and a field, whose text grows to 16px.

| Control                                               | Pointer | Touch, drawn | Touch, hit area |
| ----------------------------------------------------- | ------- | ------------ | --------------- |
| `Button`, every size                                  | 22–32   | unchanged    | 36              |
| `Switch` (36 × 20), `Checkbox`, `RadioGroupItem` (16) | —       | unchanged    | 36              |
| `Tabs` trigger                                        | 28      | unchanged    | 36              |

| Part                                                                       | Pointer  | Touch                      |
| -------------------------------------------------------------------------- | -------- | -------------------------- |
| `Input`, `HighlightedInput` (so `QueryBox`'s field)                        | 28       | 32, at 16px text           |
| The search field of `FilterMenu` and of a filtering `DropdownMenu` submenu | 32       | unchanged, at 16px text    |
| `Select` trigger and `SelectButton`, default / `sm`                        | 28 / 24  | 32 / 24                    |
| `DropdownMenu` items, `Select` items, `FilterMenu` rows                    | 28       | 36                         |
| `QueryBox` suggestions                                                     | 32       | 36                         |
| `RadioGroup` rows                                                          | 12 apart | 20 apart, centres 36 apart |

Sizes are in CSS pixels. "Pointer" is what a mouse gets, and what the [Density](/ui/guidelines/foundations/density/index.md) page's sizes are. A `Select` trigger is as tall as a field, so the two line up in a form, and its text grows with a field's, to 16px; a `SelectButton`, which a `FilterMenu` that picks one value in a form opens from, does the same.

```tsx
import { PROFILE, TIME_ZONES } from "@orz/fixtures/account.ts";
import { Button } from "@orz/ui/components/button";
import { Checkbox } from "@orz/ui/components/checkbox";
import { FrameBar } from "@orz/ui/components/frame";
import { GroupHeading } from "@orz/ui/components/group-heading";
import { Input } from "@orz/ui/components/input";
import { Label } from "@orz/ui/components/label";
import { RadioGroup, RadioGroupItem } from "@orz/ui/components/radio-group";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@orz/ui/components/select";
import { Switch } from "@orz/ui/components/switch";
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@orz/ui/components/tabs";
import { toast } from "sonner";

const NOTIFY = [
  { value: "all", label: "All activity" },
  { value: "mentions", label: "Mentions and assignments" },
  { value: "none", label: "Nothing" },
];

export function AccountSettings() {
  return (
    <Tabs variant="framed" defaultValue="profile" className="max-w-md">
      <FrameBar>
        <TabsList>
          <TabsTrigger value="profile">Profile</TabsTrigger>
          <TabsTrigger value="notifications">Notifications</TabsTrigger>
        </TabsList>
      </FrameBar>
      <TabsContent value="profile" className="p-4">
        <form
          className="grid gap-4"
          onSubmit={(event) => {
            event.preventDefault();
            toast.success("Profile saved");
          }}
        >
          <div className="grid gap-2">
            <Label htmlFor="touch-name">Display name</Label>
            <Input
              id="touch-name"
              autoComplete="nickname"
              enterKeyHint="done"
              defaultValue={PROFILE.name}
            />
          </div>
          <div className="grid gap-2">
            <Label htmlFor="touch-time-zone">Time zone</Label>
            <Select defaultValue={PROFILE.timeZone}>
              <SelectTrigger id="touch-time-zone" className="w-full">
                <SelectValue />
              </SelectTrigger>
              <SelectContent>
                {TIME_ZONES.map(({ value, label }) => (
                  <SelectItem key={value} value={value}>
                    {label}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
          </div>
          <div className="flex items-center gap-2 touch:min-h-touch">
            <Checkbox
              id="touch-show-email"
              defaultChecked={PROFILE.showEmail}
            />
            <Label htmlFor="touch-show-email">
              Show my email on my profile
            </Label>
          </div>
          <Button type="submit" className="justify-self-end">
            Save profile
          </Button>
        </form>
      </TabsContent>
      <TabsContent value="notifications" className="grid gap-4 p-4">
        <div className="grid gap-2">
          <GroupHeading id="touch-notify">Notify me about</GroupHeading>
          <RadioGroup aria-labelledby="touch-notify" defaultValue="mentions">
            {NOTIFY.map(({ value, label }) => (
              <div key={value} className="flex items-center gap-2">
                <RadioGroupItem value={value} id={`touch-notify-${value}`} />
                <Label htmlFor={`touch-notify-${value}`}>{label}</Label>
              </div>
            ))}
          </RadioGroup>
        </div>
        <div className="flex items-center justify-between gap-4">
          <Label htmlFor="touch-email">Send them by email</Label>
          <Switch id="touch-email" defaultChecked />
        </div>
      </TabsContent>
    </Tabs>
  );
}
```

Press **Touch** and **Pointer** in turn. The field and the select change, to make room for the field's larger text, and so does the tabs' bar, a strip along the edge of a frame that clips, which grows to 36px. **Save profile**, the checkbox, the radio buttons and the switch keep their size and take hit areas, and under **Notifications** the radio rows move apart so their hit areas do not overlap. Open the time zone select to see its items made 36px rows.

`touch:` follows the primary pointer, so a touchscreen laptop driven by its trackpad keeps the pointer sizes. `data-pointer="coarse"` or `"fine"` on an element forces either set on everything inside it, which is how the **Touch** button above previews a phone on a desk. Where they nest, the nearest one decides: a **Pointer** example on a page set to touch sizes is drawn for a pointer.

### Your own controls

A control you build yourself takes the same room the same way:

- A row that is tapped is at least 36px tall: `touch:min-h-touch`.
- A small control in a dense row keeps its size and adds the hit area: `relative touch:hit-area`. The `::after` belongs to the positioned element, so `relative` (or any positioning) is required. On touch the control has no baseline and lines up with text by its middle, so a flex or grid row that lines it up with `items-baseline` adds `touch:items-center`. It also keeps the room its neighbours need, as the next section says.
- A link or a text button on a line of text, such as a name in a header or a command at the end of a sentence, takes `relative touch:hit-area-inline` instead. Its hit area is the same, and it keeps its baseline, so its words stay on the line. Unlike `hit-area`, it does not keep the hit area out of a scroller's overflow, so leave the rest of the hit area above and below it, as a strip 36px tall or a padding does. Text cut short (`truncate`) would cut the hit area off at its own height, so on touch it clips only along the line: `touch:overflow-x-clip touch:overflow-y-visible`. A clip lets a flex or grid item shrink no narrower than its words, so it is never cut and runs past its cell; such an item adds `touch:min-w-0`, the room to shrink that `truncate` gives it elsewhere.
- A field takes `touch:h-field-touch`, the height its 16px text needs, as [Text fields](#text-fields) says.
- Anything else that changes for a finger, such as a keyboard shortcut hint, uses `touch:` too, not Tailwind's `pointer-coarse:`, which no `data-pointer` reaches.
- Tools that hover reveals hide only under `can-hover:`, which holds where the primary pointer can hover, so they stay shown on a phone and under a fine pointer that cannot hover. A `data-pointer` ancestor sets it too.

### Spacing between targets

**On touch no two neighbouring targets stand closer than 36px, centre to centre.** Two that stand side by side, each narrower than that, or one above the other, each shorter, are at least that far apart, so their hit areas do not overlap: a tap on one never lands on the other, and which comes first in the DOM decides nothing.

@orz/ui's parts keep that room themselves, so a row or a toolbar of them writes nothing for touch:

- An icon `Button`, and so a `ToolbarButton` and every `⋯`, reserves the rest of 36px beside it as margin. A margin you give it in `className` (`ml-auto` to push it to a bar's end) replaces that room on its side.
- A text `Button` is at least 36px wide: it is as wide as its words, which CSS cannot read to leave the rest beside it, so a short label is drawn that wide. A segment of a `SegmentedControl` and a tab are at least that wide too, since their faces join.
- A `Toggle` keeps the room above and below it, so the lines of a set of chips that wraps stand apart, and is at least 36px wide.
- An `InfoPopover`'s (i) keeps the room above and below it, so the line of the label it stands after is 36px tall.
- A `ListItem` that holds a control or is one, a `Table` row that holds one (a box, a select, a button, a field, a `TableRowLink`), a menu's item and a tree's row are at least 36px tall, so their targets stand that far from the next row's; a `RadioGroup` spaces its rows the same.
- A strip of small controls along the edge of a box that clips, such as a `Card` header that holds an action or a link, a block's header and its **Show all** bar, a `Pane` toolbar or title bar, a framed `Tabs` bar or the attachment viewer's title bar, is at least 36px tall, its controls centred in it.
- `MarkdownEditor`'s completion rows are 36px tall, and the toolbars it puts up after a paste, the paste's options and the offer to compare two images, are a strip that tall, each button keeping its size and taking a 36px hit area, as a text `Button` does.

With that room, fewer commands fit on a `Toolbar` at the same width. It hides no words on touch, since no tooltip would say them under a finger: a command that does not fit moves into its `⋯` whole, words and all ([Toolbars](/ui/guidelines/patterns/toolbars/index.md)).

A small control you draw yourself reserves the room the same way: `touch:mx-hit-xs` beside it for an `xs` one, `hit-sm` for an `sm` one, `hit` for a default one, `hit-lg` for a large one. A stack of them outside a `ListItem` gives each row `touch:min-h-touch`, and a row of buttons that wraps keeps its lines apart by twice the token, `touch:gap-y-[calc(2*var(--spacing-hit))]` for default ones. The tokens follow the style's control sizes, so the centres stand 36px apart in every style.

Four cases may stand closer:

- **A control and its own label.** A `Checkbox`, `RadioGroupItem` or `Switch` and the text that toggles it do the same thing, so these controls reserve no room beside them. A link in that text is another target: keep it away from the control, or make the whole row the label.
- **A small control beside a target at least 36px across in the direction they neighbour**: its width for two side by side, its height for one above the other, such as a row's link, a tree row or a field. The small one's hit area may take a strip of the large one, which keeps at least 36px of its own.
- **Marks placed by data on a track**, such as a seek bar's chapter marks under its thumb. Where they stand is the data's, not the layout's.
- **Links in running text.** A link inside a sentence stands where the words put it, and the line height of the text decides how far it is from a link on the next line, as WCAG's inline exception allows ([2.5.8](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html)). A list of links on their own lines is not running text: its rows take `touch:min-h-touch`.

Inside a box that clips or scrolls (`overflow-hidden`, `overflow-auto`), a hit area that crosses the box's edge is cut off there; it never makes the box scroll. An icon button's own room already keeps its hit area inside the box at the side. Above and below a control, and beside one that keeps no room of its own, leave the rest of the hit area between the control and the edge: give the strip that holds them `touch:min-h-touch` and centre them in it, or pad by the token of the control's size (`touch:pr-hit-xs` beside an `xs` one). @orz/ui's own frames, bars and table rows already leave it for their controls.

**Do**

Keep the default sizes and let a coarse pointer add the hit areas and the room between them. One layout serves the mouse and the thumb.

**Don't**

Draw controls larger for touch, or branch on screen width to do it: the room between targets is what keeps a thumb on the right one, a tablet is wide and touched, and a narrow desktop window is still clicked.

## Text fields

- Fields are 16px text on touch at every width: `Input`, `Textarea`, `HighlightedInput`, the search field of a `FilterMenu` or of a filtering `DropdownMenu` submenu, a log's search, and `CodeEditor` and `MarkdownEditor`, read-only ones too, as they still take the focus, all are. Safari zooms the page into a field whose text is smaller ([how Safari decides](https://thingsthemselves.com/no-input-zoom-in-safari-on-iphone-the-pixel-perfect-way/)), and leaves it zoomed after, on a tablet as on a phone. A field you build takes `text-base md:text-ui touch:text-base` on its own element, since one that inherits its size takes the small text of the bar or the row it stands in, and `h-control touch:h-field-touch` for the height that text needs, so it lines up with ours.
- Give a field the keyboard it needs: `type="email"`, `inputMode="numeric"`, `autoComplete`, and `enterKeyHint` (`"search"`, `"send"`, `"next"`) for the label on the return key.
- Do not focus a field on arrival on a phone; that raises the keyboard over a page the person came to read. Ask `useMediaQuery(POINTER_FINE)` first, as [Desktop & pointer](/ui/guidelines/platforms/desktop-and-pointer/index.md) shows. `FilterMenu` asks for itself: without a fine pointer it opens with the focus on its list, so the keyboard stays down over the rows until the search field is tapped. A filtering `DropdownMenu` submenu does the same: without a fine pointer its filter box waits for a tap.
- Never turn off pinch zoom (`maximum-scale=1`, `user-scalable=no`): people who need larger text zoom ([WCAG 1.4.4](https://www.w3.org/WAI/WCAG22/Understanding/resize-text.html)).

## Safe areas

A phone's screen has a notch or an island at the top, rounded corners, and a home indicator at the bottom; in landscape the notch is on a side. With `viewport-fit=cover` in the viewport meta tag the page draws edge to edge, under all of them, and each edge that holds content pads itself by the matching inset:

```tsx
<header className="sticky top-0 pt-[env(safe-area-inset-top)] pl-[max(1rem,env(safe-area-inset-left))] pr-[max(1rem,env(safe-area-inset-right))]">
<footer className="fixed inset-x-0 bottom-0 pb-[max(0.5rem,env(safe-area-inset-bottom))]">
```

`max()` keeps the usual padding where the inset is zero, which is everywhere but a phone. A background reaches the edge; only the content moves in.

`Sheet` and `Toaster` pad their own edges already. A `className` padding on `SheetContent` adds to the inset rather than replacing it; a `Toaster` given its own `offset` or `mobileOffset` replaces the inset with it, so add the inset there yourself. What is left to the app is its own fixed and sticky bars and its page gutters; anything that sticks under a header padded this way is offset by the same `env(safe-area-inset-top)`.

## The on-screen keyboard

A keyboard opening shrinks only the visual viewport: the page keeps its height, and a sticky `bottom: 0` lands behind the keyboard. Two hooks keep the page in the strip that is left:

- **`useVisualViewportInsets()`**, mounted once at the app's root, publishes `--vv-top` and `--vv-bottom` on `<html>`. A sticky edge rides the keyboard with `bottom: var(--vv-bottom, 0px)`, so a composer stays right above it.
- **`useScrollInsets({ top, bottom })`** declares the page's sticky header and composer, so every `scrollIntoView`, and the anchor and step landings of `revealBlock`, stop clear of them and of the keyboard.

```tsx
import { useScrollInsets } from "@orz/ui/hooks/scroll-insets";
import { useVisualViewportInsets } from "@orz/ui/hooks/viewport-chrome";

function Thread() {
  const header = useRef<HTMLElement>(null);
  const composer = useRef<HTMLFormElement>(null);
  useVisualViewportInsets();
  useScrollInsets({ top: [header], bottom: [composer] });
  return (
    <>
      <header ref={header} className="sticky top-0">…</header>
      <main>…</main>
      <form
        ref={composer}
        className="sticky"
        style={{ bottom: "var(--vv-bottom, 0px)" }}
      >
        …
      </form>
    </>
  );
}
```

A `Dialog` sits mid-screen with the keyboard under it; keep one that takes input to a field or two, so its buttons stay above the keyboard. Anything longer is a page or a `Sheet`.

## Auto-hiding header

On a phone a sticky header is a large share of a small screen. On a long page that is read by scrolling, a thread or a log, `useAutoHideHeader(header, enabled)` slides it away as the reader scrolls down and back as they scroll up, the way Safari's toolbar does.

```tsx
import { useElementHeight } from "@orz/ui/hooks/use-element-height";
import { SM_UP, useMediaQuery } from "@orz/ui/hooks/use-media-query";
import { belowHeader, useAutoHideHeader } from "@orz/ui/hooks/viewport-chrome";

const header = useRef<HTMLElement>(null);
useAutoHideHeader(header, !useMediaQuery(SM_UP), pathname);
const height = useElementHeight(() => header.current, 56);

<header
  ref={header}
  data-header-follow=""
  className="sticky"
  style={{ top: belowHeader(0) }}
>
…
<h2 data-header-follow="" className="sticky" style={{ top: belowHeader(height - 1) }}>
```

- Enable it on a phone only; on a wider screen the header costs little and moving it distracts.
- Mount it once, in the app's shell, so whether the header moves never depends on which page the reader is on. Pass the route's path as its third argument: each new page then arrives with the header in view, as a full load would.
- A layer pinned under the header (a list's group heading, a toolbar) takes `top: belowHeader(offset)` and `data-header-follow` too, or a strip of page opens between the two while the header moves. Pin it one pixel under the header's height, so it tucks under the header's border: at some zoom levels Firefox snaps the two to different device-pixel rows and leaves a hairline of page between them.
- Only the reader's own scrolling moves it. A jump to an anchor keeps it where it is, and it settles fully in or out when scrolling stops.
- Do not use it on a short page, a form, or a page whose header holds the action people came for: that action then disappears under their thumb.

## Gestures

| Gesture                           | Who owns it                             | What the app does                                                                                                                                                                                                 |
| --------------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Swipe from the left or right edge | The system: back and forward            | Nothing within 20px or so of the edge, so the back swipe always works                                                                                                                                             |
| Pull down at the top              | The browser: refresh                    | Leaves the page's overscroll alone; `overscroll-contain` on a panel that scrolls inside the page                                                                                                                  |
| Pinch                             | The browser: zoom                       | Never disabled; a canvas that zooms its own content (an image viewer) takes it only inside itself                                                                                                                 |
| Long press                        | The system: select text, preview a link | Nothing a control does not also do: a long press that selects a row repeats the row's checkbox, and a [`SelectionBar`](/ui/guidelines/patterns/actions-and-buttons/index.md#acting-on-a-selection) leads back out |
| Swipe on a toast, a row           | The app                                 | Only as a shortcut: the toast also leaves on its own, the row's action is also in its menu, a delete still offers **Undo**                                                                                        |
| Drag a row by its handle          | The app                                 | Only from the handle: anywhere else on the row the page scrolls, and the row's pair of move buttons does the same with taps ([Reordering](/ui/guidelines/patterns/reordering/index.md))                           |

Every gesture an app adds has a control that does the same thing with one tap, and anything that follows a path or needs two fingers works with a single pointer too ([WCAG 2.5.1](https://www.w3.org/WAI/WCAG22/Understanding/pointer-gestures.html)). A tap acts when the finger lifts, not when it lands, so a finger that lands on the wrong control can slide off; @orz/ui's buttons already do.

In the example at the top, archive a conversation from its `⋯` menu: the toast that says so can be swiped away, leaves on its own, and holds the **Undo**.

A selectable tree starts selecting from the row's `⋯` menu, its **Select**, since a link's long press is the system's; after the first row a tap toggles a row instead of going, and the menu's **Clear selection** or the `SelectionBar`'s brings the taps back to going.

`Dialog` and `Sheet` lock the page behind them while they are open, and let a scroller inside them, a code diff included, scroll on its own.

## On each platform

- **Pointer.** The compact sizes from [Density](/ui/guidelines/foundations/density/index.md), hover, shortcuts: [Desktop & pointer](/ui/guidelines/platforms/desktop-and-pointer/index.md).
- **Touch.** Everything on this page. Preview it on a desk with the **Touch** button above any example, or Storybook's **Pointer** toolbar; check it on a real phone before shipping, because neither emulates the keyboard, the notch or the system's gestures.

## In the demos

- [Settings](/ui/demos/settings/index.md): On a phone the sections are a list that pushes each one, with labels on the leading edge and controls on the trailing edge, as the phone's own settings are.
- [Sign in](/ui/demos/sign-in/index.md): On a phone the module is the whole screen. Forgot password? leads to a code field that opens the number pad and offers the code from the mail, and the email fields bring the email keyboard.
- [Admin](/ui/demos/admin/index.md): On a phone the workspace menu keeps only its mark, and the sections that do not fit wait in the ⋯ at the end of the bar.
- [Tasks](/ui/demos/tasks/index.md): On a phone the filters that do not fit wait in the toolbar's ⋯, the board shows a column at a time with the next at the edge and lifts a card held still under a finger, and a task opens as a Sheet that fills the screen.
- [Mail](/ui/demos/mail/index.md): On a phone a long press selects a conversation, Compose sits under the thumb, and the reply box rides above the on-screen keyboard.
- [Notes](/ui/demos/notes/index.md): On a phone a note opens to be read, and the on-screen keyboard comes up only when you press Edit.
- [Pull request](/ui/demos/pull-request/index.md): Press Touch in the bar above: the jobs' rows make room for a thumb, Details and Re-run keep their size and take hit areas, and a log or a diff scrolls inside its own box.
- [Repository](/ui/demos/repository/index.md): On a phone the tree fills the screen; a file or folder replaces it, with a link back to the files at the top.
- [Config editor](/ui/demos/config-editor/index.md): On a phone the file tree folds into a Select in the file's heading line, its rows at a thumb's size, and the error line under the editor grows to one too.
- [Binary inspector](/ui/demos/binary-inspector/index.md): On a phone the structure is a Select above the bytes and the inspector a Sheet, while Revert… keeps its word because nothing undoes it.
