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

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

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.
  • 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.