Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 2.02 KB

File metadata and controls

39 lines (27 loc) · 2.02 KB

Text Fields

Text fields require visible label text next to the field which must be set as the .accessibilityLabel of the TextField.

Or provide visible labels using LabeledContent and then an .accessibilityLabel is not required. Don't use .labeledContentStyle(.vertical) or else VoiceOver won't be able to double tap to activate the TextField.

VoiceOver users must hear the label text spoken when focused on the text field.

Don't use placeholder text which has insufficient contrast and disappears after the user enters a value.

Notes:

  • Use .textFieldStyle(.roundedBorder) to make the TextField visually identifiable.
  • Use .border(.secondary) to give the border a 3:1 contrast ratio in light and dark mode.
  • Use .keyboardType to specify the keyboard displayed on input.
  • Use .textContentType to enable form AutoFill for each TextField.

VoiceOver Bugs:

  • VoiceOver operation is blocked when using LabeledContent with a TextField and .labeledContentStyle(.vertical) because VoiceOver users cannot double tap to activate the TextField and enter a value. Bug reports should be filed with Apple.

Applicable WCAG Success Criteria


Copyright 2023 CVS Health and/or one of its affiliates

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.