TextField

Single-line text input. Text entry, IME composition, selection and the cursor are the platform's own — only the look changes.

Enter a valid email address.

Usage

Web (React)

const [email, setEmail] = useState("");
return (
  <DotwearTextField
    label="Email"
    type="email"
    value={email}
    onChange={setEmail}
    error={emailError} // undefined hides the message
  />
);

iOS (SwiftUI)

TextField("Email", text: $email)
    .textFieldStyle(.dotwear)
    .dotwearFieldError(emailError)   // nil hides the message

React Native

const [email, setEmail] = useState("");
return (
  <DotwearTextField
    label="Email"
    keyboardType="email-address"
    value={email}
    onChangeText={setEmail}
    error={emailError} // undefined hides the message
  />
);

Flutter

DotwearTextField(
  label: 'Email',
  controller: email,
  keyboardType: TextInputType.emailAddress,
  error: emailError, // null hides the message
);

Variants

VariantUse for
defaultNormal input
errorInvalid input: danger-colored border and a message below

States

StateAppearance
defaultBorder color border, background bg
focusedOne-dot focus ring outside the border (the border width does not change, so text never moves)
errorDanger-colored border and message
disabledDisabled color for border and text

React API

PropDescription
labelRequired. Shown above the field and used as its accessible name
value / onChange(value, event)onChange receives the new string first, so onChange={setEmail} works
errorError message below the field (aria-invalid and aria-describedby are set). undefined hides it
…input propsAny <input> attribute (type, placeholder, disabled, autoComplete, …)

SwiftUI API

APIDescription
.textFieldStyle(.dotwear)Applies the Dotwear look to a TextField or SecureField
.dotwearFieldError(_ message: String?)Shows an error message below the field. nil hides it

React Native API

PropDescription
labelRequired. Shown above the field and used as its accessibilityLabel
value / onChangeTextSame as TextInput
errorError message below the field, also read as the field's hint. undefined or null hides it
disabledNot editable, in disabled colors
…TextInput propsAny TextInput prop (placeholder, keyboardType, secureTextEntry, autoComplete, …)

Flutter API

ParameterDescription
labelRequired. Shown above the field and read as its name
controller / onChangedSame as TextField
errorError message below the field, also read as the field's hint. null hides it
enabled / placeholderDisabled colors / hint text shown while empty
keyboardType, obscureText, autofillHints, …Passed to the standard TextField
DotwearFieldFrameThe frame alone, to wrap your own TextField (with DotwearFieldFrame.decoration(context))

Accessibility

  • Web: the label is a <label for>, and the error is linked with aria-describedby and aria-invalid.
  • iOS: VoiceOver reads the error message as the field's hint, so it is announced together with the field.
  • React Native: a standard TextInput. The label is its accessibilityLabel and the error its accessibilityHint, so VoiceOver and TalkBack announce them with the field.
  • Flutter: a standard TextField. The label is read as its name and the error as its hint.
  • The whole 44 pt row is tappable, not just the visible border.
  • Placeholders are not labels: keep a visible label when the field needs one.