---
title: "Input, events, and commands"
description: "An input handler should update raw draft state on every edit so live search, validation and button enablement follow typing."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Input, events, and commands

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/learn/contract-for-humans/input-events-and-commands: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Bind a controlled text field's current value and its editing action:

```text
input value=query input=search placeholder="Search" aria-label="Search"
textarea value=body input=editBody
```

An `input` handler should update raw draft state on every edit so live search,
validation and button enablement follow typing. A text field fires `change` on
Enter or blur; its handler should normalize the draft. A textarea commits when
editing ends. Use `submit` for explicit submission.

A text field is the platform's own by default (LLP 1104): `input` with no type
or `text`, `email`, `password`, `search`, `tel`, `url`, `number`, and `textarea`
outside the Markdown editor. On the web it inherits the page's font and
colour, as a CSS reset does. Disabled and placeholder appearances are the
platform's; CSS's `::placeholder` block, under the field or in a `style`,
colours its placeholder (`color` alone, its alpha its own). A background, border or radius makes it your own box, as in a
browser; `appearance="none"` says so explicitly. A row on any conditional
class or value arm counts. `appearance="auto"` asks for the native field and
refuses those rows; `background-clip` and `background-attachment` are allowed.
Appearance is a literal, from the class then your own attribute; use `if`
with two fields to switch it.

`input` and `change` carry the control's new value as the final action argument:
a string for a text field, textarea or `select`, a boolean for a checkbox or
switch, the radio's `value` for `type="radio"`, a number for `type="range"`, and
a `Picked[]` for a file input. An action taking one more parameter also
hears the target as the event leaves it, an `InputEvent`: its `value` (a
checkbox's own), `checked`, and a text field's `selectionStart`, `selectionEnd`
and `selectionDirection` ([form controls](https://exact.expo.dev/reference/contract-grammar/events.md#form-controls-radio-inputevent-setselectionrange)).
`hover` carries a boolean; `key` (keydown) and `keyup` carry a key name, and to an action that
takes one more parameter its `KeyboardEvent` (the modifiers, the physical key `code`,
whether it is an auto-`repeat`, and `isComposing`, whether an input method was composing). Captured arguments precede
the payload: `input=edit(item.id)` calls the bound action with the id followed
by the new text. This syntax is binding, not immediate evaluation.

Use explicit types when they make the interface clear; omitted action parameter
types can be inferred from event sites. There is no inline `() => …` handler;
a `key` action claims its key with the host command `preventDefault()`, and
keeps it from its ancestors' `key` handlers with `stopPropagation()`
([keys](https://exact.expo.dev/reference/contract-grammar/events.md#keys)).

The complete event inventory and payload groups are in the
[event reference](https://exact.expo.dev/reference/contract-grammar/events.md). HTML controls include `select` and
`option`, and `progress`: with `value` and `max` the platform's progress bar,
with no `value` its activity indicator ([progress](https://exact.expo.dev/reference/contract-grammar/events.md#progress-progress)); inspect [the control tests](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/cli/tests/it/controls.rs) for
the checkbox/switch, radio, range, select and date/time conventions instead of
assuming a browser Event object. `input type="radio"` is HTML's: the radios of
one `name` are a group, exclusive, and the arrow keys move the check among them.

An action can issue host commands such as `focus("editor")`,
`blur("editor")`, `copyText(text)`, and `openURL(url)`. Use an element's `id` for
commands that address a node. The [command inventory](https://exact.expo.dev/reference/contract-grammar/host-commands.md)
and linked checks describe the more specialized picker, sharing, formatting,
scrolling, and delivery commands. Commands are distinct from pure functions:
`openURL` does not return a Contract value, and a `fn` cannot issue it; to hear
whether the URL opened, name an element, `openURL(url, "opened")`, whose `change`
hears `opened` or `failed`. On the web, pass `target="_self"` (`openURL(url,
target="_self")`) to redirect the current tab to an `http` or `https` URL with
`location.assign` (preserving Back); native hosts ignore `target`. The compiler does not check most commands'
arguments, and hosts differ: headless Linux does not carry
`openURL`. Check the host you target.

A file `input` with no `accept`, an empty `accept`, or `accept="*/*"` offers any
file. A specific `accept` must be literal; types other than images and video
must be listed in `app.json`'s `file_handlers`. `showPicker` delivers a `Picked[]`
to the addressed element's `change` handler, while `showOpenFilePicker`,
`showDirectoryPicker` and `showSaveFilePicker` deliver `doc:` handle strings;
cancellation uses `cancel`. Where a browser has no open pickers (Firefox,
Safari) they refuse with `cancel` too: read `exactPage().canOpenFiles` to tell
that from a person's dismissal and offer an import instead. A save there still
works: what the app writes to its handle downloads under the suggested name. File content, durable storage, and permissions belong
in the data module. See [file-picker syntax](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/corpus/file-pickers.contract).

On tvOS, `focusGuide="auto"` on a container guides a remote move entering its
box to the descendant that last held focus, or its first focusable descendant.
Moving within the container keeps UIKit's geometry. Other hosts ignore the
attribute and retain their normal focus order.

## Choosing a native button

A `button` is the platform's own control by default. Giving it a background,
border or radius, rich children, or rows the native control cannot support
makes it your bare box. A class counts too, even when a row or incompatible
child appears on only one conditional arm. Write `appearance="none"` to ask
for your box explicitly, or `appearance="auto"` to require a native button and
get an error for unsupported rows or children. For example:

```contract
component NativeButtonExample
  state presses = 0
  action send
    presses = presses + 1
  view
    column gap=12
      button buttonStyle="filled" press=send testId="send"
        text "Send"
      text `${presses}` testId="presses"
```

Its first `text` is the title, its second is the subtitle, and one
`image "symbol:…"` is the symbol. These are semantic fields; the platform lays
them out. An image before/after the texts goes leading/trailing with
`flex-direction="row"`, or top/bottom with `flex-direction="column"`. A
symbol-only face needs a nonempty `aria-label`. macOS reports stand-ins where
`NSButton` cannot express gap, subtitle or wrapping.

`font-size`, `font-weight`, `color`, `white-space`, `line-clamp` and `text-align`
can be on the button or its texts; a text's own row wins. Apple uses the
platform's typography unless a row is written there (a class counts); the web
inherits the page's font and colour. Tab/menu projections keep the existing
ancestor `text-transform` on their projected title. `white-space="nowrap"` is one truncated
line; `line-clamp=2` caps wrapping; `text-align="start"` places the face at the
start of the box. An image can set its own `-exact-tint-color`, `font-size` and
`font-weight`; otherwise its symbol follows the title. Image `width`, `height`
and `object-fit` are refused.

`gap`, or the gap for the chosen axis (`column-gap` in a row, `row-gap` in a
column), sets image-to-title spacing. Leave it absent for the platform's
spacing. Title-to-subtitle spacing stays the platform's. `align-items` and
`justify-content` accept only `center`. `-exact-control-size` takes `mini`,
`small`, `medium`, `large`; `-exact-corner-style` takes `dynamic`, `small`,
`medium`, `large`, `capsule`. These are styleable rows for native buttons only,
but a segmented control (a `tablist` or `radiogroup`) also takes
`-exact-control-size`, which makes it the platform's segmented control of that size.
With explicit `appearance="auto"`, `border-radius` sets a radius and wins over
the named corner style. Under the default, a radius makes the button bare. `padding`
and its longhands set content insets; leave them absent for the style's own.

`pointer-events="none"` passes touches through; `auto` restores them. Disabled
buttons keep authored colours; bind `opacity` when you want dimming. Native
buttons can use `commandfor` with `command="show-modal"`, `"show-popover"` or
`"toggle-popover"`, and `popovertarget`, including bound or empty targets (empty
means no target). `href`, `action` and swipe attributes stay refused.
`-exact-enabled` transitions are not available. Handlers are `press`, `focus`,
`blur`, `key`, `keyup` and `hover`.

The kernel's optional host measure hook supplies the fitting size before the
first frame and handles wrapping at the offered width. Existing hosts keep
their intrinsic-size report until they implement it.

`buttonStyle` needs a native button. With none, a button is the platform's
default: plain tinted text on iOS, as UIKit's and SwiftUI's own button is, a push
button on macOS, and bordered on the web, where a bare text button reads as
unstyled. So say what the action is: `filled` for the screen's main action,
`bordered` for one that must read as a button, and nothing for a
secondary or inline one (`contract vocab button`). If the default
makes your button bare, `lower-button-style` names the first reason: remove it,
or write `appearance="none"` without `buttonStyle`. The accepted styles are `plain`, `gray`,
`tinted`, `filled`, `borderless`, `bordered`, `bordered-tinted`,
`bordered-prominent`, `glass`, `prominent-glass`, `clear-glass`, and
`prominent-clear-glass`. This is a declared host-policy property, not a CSS
standard property. It can live in a style and can choose among checked literal
names. `appearance`, however, must resolve to a literal after class application;
use a view branch if switching between native and custom buttons.

Native buttons refuse backgrounds, borders, shadows, filters, `font-family`,
other typography or inner layout and `-exact-press-scale`. A refusal names a
custom `button` (without `appearance="auto"`) as the alternative. Size, place,
opacity and transforms remain admitted. `accent-color` tints the styles that support it
(`gray`, `bordered`, `glass` and `clear-glass` ignore it). Follow
[the native-button fixture](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/scripts/fixtures/native-buttons.contract) and
[its compiler checks](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/contract/lower/src/controls.rs) for the admitted forms.

A settings screen is a grouped list: a `list` whose `appearance` is the literal
`auto`. Its children are `section`s. A section's first child may be a `header`
and its last a `footer`, each holding a `text`; everything between is its rows.
A `header` may instead hold boxes of your own, such as a `row` of an `image`
and a `text` (an avatar beside a name). That header is custom: it keeps its
views in the platform's header, which still pins in a plain list, and its texts
name it for a screen reader. Several bare texts are refused; lay them out in a
`row` or a `column`. A `footer` holds one `text` only.
A row is read by its shape: an optional leading `image "symbol:…"`, a `text`
title, an optional second `text` (a value) or a `column` of two texts (a
subtitle), and an optional trailing accessory — a `forward-chevron` or
`checkmark` image, a checkbox or switch `input`, or a `button` holding only
`image "symbol:info"`. `destructive` draws a row red. Any other row is custom
and keeps its own views. A row with an authored `height`, `background-color` or
corner radius also keeps its views, including a row laid out as a column. A
subtitle column does too when it writes any of those or `min-height`. Authored
`align-items` or `justify-content` on either a nested column or a row laid out
as a column keeps its views too. Classes count as authored. Such nested
columns omit subtitle block padding when lowering can establish that their
row or column writes a box. Literal values and ternary arms are recognized;
a `none` arm keeps the platform padding. Other expressions keep that padding
because they may evaluate to `none`. Write explicit padding to control it.
The title-to-subtitle gap stays the platform's
unless you write your own gap. A row's own `min-height` alone still works
on a standard cell. A section written `background-color="transparent"` has no card: its rows sit on the list's background with no separators or corners, as a profile header does (LLP 1084 §6.2). That literal is the only `background-color` a section takes, and not beside a `class`; a section that gains and loses its card is two sections under `if`.

```text
list appearance="auto" listStyle="inset-grouped" flex=1
  section
    header
      text "Account"
    button press=openProfile
      image "symbol:person"
      text "Profile"
      image "symbol:forward-chevron"
    footer
      text "Who can see you."
```

A section's `box-shadow`, written directly or in its `class`, belongs to the
card around its rows, with the platform's corners. It excludes the header and
footer. State overrides and the shadow’s transition follow the card. On iOS
the rows remain UIKit list cells. A section without its card
(`background-color="transparent"`) takes no shadow. Keyframe shadow animation
on a grouped section is not supported yet and fails the build; use a shadow
`transition` instead. On iPad, pointer hover over a grouped section does not
activate its `:hover` shadow yet.

Row buttons and their detail accessories stay bare by default, preserving the
cell's title and action. Explicit `appearance="auto"` makes one a custom native control.

`listStyle` is `inset-grouped` (the default), `grouped`, `plain` or `sidebar`,
a literal. iOS draws UIKit's own list (`UICollectionView` with a list
configuration); the other hosts draw a sheet measured from it, and your own
attributes replace any of its rows. `sidebar` is UIKit's sidebar list at every
width, for a list of places to go (folders, sections); the hosts with no
sidebar list draw it as the plain list. A section's own `margin-top` or
`margin-bottom` is the space iOS leaves there too, collapsed with its
neighbour's as on the web (LLP 1084 §6.4).
The rest of a section's layout is the platform's, its rows one under another
across the card: besides those margins a section takes only `display` `"block"`
or `"none"` of its own layout, written or from its `class`, and the compiler
refuses any other (`lower-grouped-list`); lay rows out yourself in a `column`.
A row is as wide as its card, `border-box`, with the cell's insets as its
padding, so `width="100%"` keeps it in the card. The separator under it is the
platform's, in the platform's colour: `border-bottom-color` alone does not
recolour it; a bottom border you write (or `border-bottom-style="none"`) takes
its place under that row (LLP 1084 D7), except on iOS under a row UIKit draws as
a standard cell, which keeps UIKit's line and draws no border of yours.
See [the grouped-list fixture](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/scripts/fixtures/grouped-list.contract)
and LLP 1084.
