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
| Variant | Use for |
|---|---|
default | Normal input |
error | Invalid input: danger-colored border and a message below |
States
| State | Appearance |
|---|---|
| default | Border color border, background bg |
| focused | One-dot focus ring outside the border (the border width does not change, so text never moves) |
| error | Danger-colored border and message |
| disabled | Disabled color for border and text |
React API
| Prop | Description |
|---|---|
label | Required. Shown above the field and used as its accessible name |
value / onChange(value, event) | onChange receives the new string first, so onChange={setEmail} works |
error | Error message below the field (aria-invalid and aria-describedby are set). undefined hides it |
…input props | Any <input> attribute (type, placeholder, disabled, autoComplete, …) |
SwiftUI API
| API | Description |
|---|---|
.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.