Chapter 5

Controls reference

5.1 Options shared by every control (ControlOptions<V>)#

Option Type Default Notes
name string required Key in submitted data. Must match /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/ and be unique in a Form.
label string '' Shown above the control (inline for checkbox/switch). Also the screen-reader name.
helperText string '' Grey line below. Replaced by the error message while invalid.
info string '' Shows an ⓘ icon next to the label. Its tooltip opens on hover (mouse), tap (touch) or F1 while the control is focused; Esc closes it. Also read by screen readers. Change later with control.infoText = '...'.
disabled boolean false Also settable later via control.enabled = false.
required boolean false Adds * to the label and fails validation when isEmpty().
requiredMessage string "<Label> is required."
validators Validator<V>[] [] See §7.
validateOn 'blur' | 'change' | 'submit' 'blur' Overridden by the form's autovalidateMode.
theme DeepPartial<Theme> none Per-instance style overrides (§9).
width number 320 Initial width; layouts call layout(width) anyway.
tabIndex number 0 Positive values come first in Tab order (like HTML tabindex).

5.2 Members shared by every control#

control.getValue(); control.setValue(v, emit = true); control.reset(); control.isEmpty();
control.validate(): Promise<string | null>;   control.setError(msg | null);   control.error;
control.focus(); control.blur(); control.focused; control.enabled = false;
control.fieldLabel = 'New label'; control.helperText = '...'; control.infoText = '...';
control.layout(width); control.layoutHeight;   control.setThemeOverride({...});
control.fieldName; control.touched; control.validateOn; control.wipe();

Events (control.on(event, handler)):

Event Arguments When
change (value, control) Value changed by the user or setValue(v, true)
input (control) Text fields: every edit
submit (control) Text fields: Enter (single-line) or Ctrl/Cmd+Enter (multi-line)
focus / blur (control) Focus changes
validate (error | null) Error state changed
resize (control) Height changed (e.g. an error appeared); layouts listen for this
press (button) Button only
complete (value, control) OtpInput only: every box filled

5.3 TextInput and TextArea#

new TextInput(ui, { name: 'city', label: 'City', placeholder: 'Jaipur', maxLength: 60 });
new TextArea(ui, { name: 'notes', label: 'Notes', rows: 5, showCounter: true, maxLength: 1000 });
Option Type Default Notes
value string '' Initial value (sanitised). reset() returns to it.
placeholder string ''
maxLength number 256 / 2000 (textarea) In code points. Hard ceiling 20,000.
allow RegExp none Per-character allow-list applied while typing and pasting.
formatters TextInputFormatter[] [] See §8.
rows number 4 TextArea only.
readOnly boolean false Selectable and copyable, not editable.
showCounter boolean false n/max at bottom right.
inputMode 'text' | 'email' | 'tel' | 'numeric' | 'decimal' | 'url' | 'search' 'text' Mobile keyboard layout.
enterKeyHint 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' 'next' Mobile Enter key label.
normalize 'NFC' | 'NFKC' | false 'NFC' Unicode normalisation.
enableInteractiveSelection boolean true false disables selection and copy/cut (Flutter equivalent).

Extra members: length, getSelection(), setSelection(start, end), selectAll(), undo(), redo(), readOnly, placeholder, showCounter.

Keyboard:

Keys Action
← → Move caret (collapses a selection)
Ctrl+← → (Win/Linux), ⌥← → (Mac) Move by word
⌘← → (Mac), Home/End Line start/end; Ctrl+Home/End jumps to document start/end in TextArea
Shift + any movement Extend the selection
↑ ↓, PageUp/PageDown TextArea: move by line/page, keeping the column
Backspace / Delete (+ Ctrl/⌥ for a word, ⌘⌫ to line start) Delete
Ctrl/⌘+A, Ctrl/⌘+Z, Ctrl+Y / ⇧⌘Z Select all, undo, redo
Ctrl/⌘+C / X / V Copy / cut / paste (through the system clipboard)
Enter TextInput: emits submit. TextArea: new line (Ctrl/⌘+Enter submits).
Esc Collapse the selection

Pointer: click to place the caret, drag to select (mouse/pen), double-click selects a word, triple-click selects all.

5.4 PasswordInput#

const pw = new PasswordInput(ui, { name: 'password', label: 'Password', required: true });
pw.on('change', (s: Secret) => meter.update(s));

Inherits the text options except multiline/rows. Defaults: maxLength: 128, normalize: 'NFKC'.

Option Default Notes
showVisibilityToggle true Eye button.
revealTimeoutMs 10000 Auto re-obscure. 0 = never.
revealLastChar 'auto' Briefly show the last typed character: 'auto' = touch devices only, or true/false.
revealLastCharMs 1000
obscuringCharacter '•'
allowPaste true Keep it on so password managers work via paste.
capsLockWarning true Helper line shows "Caps Lock is on".

Built-in behaviour: copy/cut blocked, no undo history, word navigation jumps to the ends, re-obscured on blur and when the tab is hidden, and the proxy switches to type=password (keyboards don't learn the value). Extra members: isRevealed, setRevealed(bool).

5.5 Checkbox#

new Checkbox(ui, { name: 'terms', label: 'I accept the terms', required: true, requiredMessage: 'Please accept.' });

Options: checked, indeterminate (shows a dash; cleared on next toggle). required means "must be checked". Members: toggle(). Keyboard: Space.

5.6 Switch#

new Switch(ui, { name: 'alerts', label: 'Security alerts', description: 'Email me about new sign-ins.', value: true });

Laid out like a list tile (text on the left, switch on the right). Options: value, description. Members: toggle(). Keyboard: Space/Enter toggle, ← off, → on.

5.7 RadioGroup<T>#

new RadioGroup(ui, {
  name: 'plan', label: 'Plan', direction: 'horizontal', value: 'free',
  options: [{ value: 'free', label: 'Free' }, { value: 'pro', label: 'Pro' }, { value: 'team', label: 'Team', disabled: true }],
});

One Tab stop for the whole group. ↑ ↓ ← → move and select (skipping disabled options); Space selects. Horizontal groups wrap to new rows when narrow. setValue() ignores values that aren't declared options.

5.8 Select<T>#

new Select(ui, { name: 'country', label: 'Country', placeholder: 'Choose…', options: [{ value: 'IN', label: 'India' }, ...] });

The menu opens in ui.overlay, flips above the field when there's no room below, follows the field while scrolling, and scrolls by wheel or touch drag (shows dropdownMaxVisible rows).

Keys (closed) Action Keys (open) Action
Enter / Space / Alt+↓ Open ↑ ↓ Home End Move highlight
↑ ↓ Change value directly Enter / Space Choose
Letters Type-ahead select Letters Type-ahead highlight
Esc Close
Tab Close and move on

Members: isOpen, setOpen(bool).

5.9 Slider#

new Slider(ui, { name: 'age', label: 'Age', min: 18, max: 99, step: 1, value: 30, format: (v) => `${v} yrs` });

Options: min (0), max (100), step (1), value, format, showValue (true). Keyboard: arrows ±step, PageUp/PageDown ±10%, Home/End min/max. Dragging captures the pointer, so a scroll view won't pan while you drag the thumb.

5.10 Button#

new Button(ui, { name: 'save', text: 'Save', variant: 'primary', onPress: async () => { await save(); } });
Option Default Notes
text required
variant 'primary' 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'
block true Fill the width; false sizes to the text.
onPress none If it returns a Promise, the button shows a spinner and ignores presses until it settles.

Members: text, variant, loading, press(). Keyboard: Enter/Space (key repeat ignored).

5.11 OtpInput#

const otp = new OtpInput(ui, {
  name: 'code', label: 'Verification code', required: true,
  length: 6, groupSize: 3, autoSubmit: true, webOtp: true,
  info: 'The code arrives by SMS.',
});
otp.on('complete', (code) => console.log('all digits entered'));
Option Default Notes
length 6 Number of digit boxes, 4–10.
groupSize 0 Visual grouping with a dash, e.g. 3 → 123 – 456.
obscure false Show • instead of digits.
autoSubmit false Emits submit when the last box is filled, so a bound Form submits immediately.
webOtp false Android Chrome: reads the code from an incoming SMS with the WebOTP API. The SMS must end with @your.domain #123456.
value '' Initial digits.

Behaviour:

Members: length, isComplete, clear(), obscure, autoSubmit.

5.12 DatePicker (calendar with optional time)#

const dob = new DatePicker(ui, {
  name: 'dateOfBirth', label: 'Date of birth', required: true,
  max: 'today', min: '1900-01-01',
});
const meeting = new DatePicker(ui, {
  name: 'meeting', label: 'Meeting',
  min: 'today', max: 'today+60',
  time: { step: 30, hour12: false, defaultTime: '10:00' },
  isDateDisabled: (iso) => [0, 6].includes(new Date(iso + 'T00:00').getDay()), // no weekends
});
meeting.getValue();   // '2026-11-24T10:30'
meeting.getDate();    // JS Date in local time
Option Default Notes
value null 'YYYY-MM-DD' or 'YYYY-MM-DDTHH:mm'. Invalid dates (e.g. 2026-02-30) are ignored.
min / max none ISO date, 'today', or 'today±N' days. Out-of-range days are struck through.
isDateDisabled none (isoDate) => boolean for weekends, holidays, booked days.
time false true or { step = 15, hour12 = locale, defaultTime = '09:00' }. Adds an hour/minute (and AM/PM) row.
locale browser Month and day names, formats, and the default week start.
firstDayOfWeek locale 0 = Sunday … 6 = Saturday.
placeholder "Select a date"
clearable !required × in the field and a Clear button in the popup.

Popup: month grid with ‹ › arrows; click the title for a month view, and again for a year view (12 years per page), so a date of birth takes a few clicks. "Today" jumps and selects; with time, picking a day keeps the popup open until Done. The popup flips above the field and stays on screen on phones.

Keys (popup open) Action
← → ↑ ↓ Previous/next day, previous/next week
PageUp / PageDown Previous/next month (with Shift: year)
Home / End Start/end of the week
T Today
Enter / Space Choose the highlighted date (month/year in those views)
Tab / Shift+Tab Calendar → hour → minute → AM/PM (time mode)
↑ ↓ or digits (time) Change hour/minute; A/P sets AM/PM; Enter closes
Esc Back from month/year view, or close

Closed: Enter / Space / Alt+↓ / F4 opens; Delete or Backspace clears. Screen readers hear the full date ("Tuesday, 24 November 2026, 11:30"), whether it's unavailable or selected, and month changes.

Values are plain local strings with no timezone, so the browser and the server always agree on the day. If you need an instant in time, combine the value with the user's timezone on the server.

5.13 PhoneInput (number with country code)#

const phone = new PhoneInput(ui, {
  name: 'phone', label: 'Mobile', required: true,
  defaultCountry: 'IN',
  preferredCountries: ['IN', 'US', 'GB'],
});
phone.getValue();   // '+919876543210'
phone.getParts();   // { country: { iso: 'IN', dial: '91', … }, national: '9876543210', e164: '+919876543210' }
Option Default Notes
defaultCountry browser region, else US ISO 3166 code.
preferredCountries [] Shown first in the menu.
onlyCountries all Restrict the list.
countries built-in ~40 Your own Country[] (iso, name, dial, pattern, min, max, trunk).
showFlags on, except Windows Windows has no flag emoji; the ISO code is shown instead.
value '' E.164; the country is detected from it.

Behaviour:

Members: countryField (a Select), numberField (a TextInput), getParts(). Exported data: PHONE_COUNTRIES, formatNational(), flagEmoji().