Visitar URL original
USWDS-Site - Form templates: Add guidance for labelling required fields by bonnieAcameron · Pull Request #1834 · uswds/uswds-site · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f0265ff
updated the forms page with Jacline's form usability best practices
bonnieAcameron Oct 14, 2022
c37d59d
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
e199013
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
29fac48
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
66a8f82
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
7fa05a5
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
a0c72a4
Update _includes/accessibility.html
bonnieAcameron Oct 21, 2022
a1f0b60
remove "error handling"
bonnieAcameron Oct 21, 2022
18eaaf9
Update placement of screen reader note
bonnieAcameron Oct 21, 2022
80509b7
update file name to reflect new content
bonnieAcameron Oct 21, 2022
72eaf07
Remove bolded note
bonnieAcameron Oct 21, 2022
420fdfd
Merge branch 'main' of https://github.com/uswds/uswds-site into bc-up…
Oct 21, 2022
c0555bc
Update accessibility.html references
Oct 21, 2022
859e349
Merge branch 'main' of https://github.com/uswds/uswds-site into bc-up…
Oct 31, 2022
5924271
Apply copyedits from code review
thisisdano Mar 7, 2023
fbdb3d9
Merge branch 'main' of https://github.com/uswds/uswds-site into bc-up…
Mar 24, 2023
b7fa18f
Add changelog
Mar 24, 2023
7fe4a2e
Fix typos
Mar 24, 2023
7c867d6
Remove text-decoration from abbr[title='required']
Mar 24, 2023
8043f40
Merge branch 'main' of https://github.com/uswds/uswds-site into bc-up…
Mar 27, 2023
f86a250
Format
Mar 29, 2023
3974a51
Change required fields section title; change styling on note
Mar 30, 2023
3032a79
Pull template-form changelog data into component-form; set both form …
Mar 31, 2023
0c2c662
Add note to changelog about use on multiple pages
Apr 6, 2023
22b6fce
Fix typo
Apr 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _components/form/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ changelog:

<div class="site-note"><strong>Note:</strong> If you are a building a form with multiple controls, also consider the <a href="{{ site.baseurl }}/form-templates/">accessibility guidelines on the “Form Templates” page</a>.</div>

{% include accessibility.html %}
{% include forms-guidance.html %}

<div id="settings" class="usa-prose site-prose margin-top-5">
<h3 class="usa-heading heading-margin-alt">Form settings</h3>
Expand Down
3 changes: 3 additions & 0 deletions _data/changelogs/component-form.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Note: This changelog is used on multiple pages:
# templates/form-templates
# components/form
title: Form
type: component
changelogURL:
Expand Down
30 changes: 0 additions & 30 deletions _data/changelogs/template-form.yml

This file was deleted.

21 changes: 0 additions & 21 deletions _includes/accessibility.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this file deleted because none of this applies anymore?

Nevermind, I see an a11y section on both guidance pages.

This file was deleted.

59 changes: 59 additions & 0 deletions _includes/forms-guidance.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<section class="usa-prose site-prose margin-top-5">
<h2 id="general-accessibility-guidance-for-forms">Accessibility guidance</h2>
<ul class="usa-content-list">
<li><strong>Don’t control element order with CSS.</strong> Display form controls in the same order in the HTML as
they appear on screen. Don’t use CSS to rearrange the form controls. Screen readers narrate form elements in the
order they appear in the HTML.</li>
<li><strong>Align validation with inputs.</strong> Visually align validation messages with the input fields so
people using screen magnifiers can read them quickly.</li>
<li><strong>Use proper markup.</strong> Group each set of thematically related controls in a fieldset element. Use
the legend element to offer a label within each one. The fieldset and legend elements make it easier for those who
use screen readers to navigate the form.</li>
<li><strong>Use legends.</strong> Use a single legend for fieldset (this is required). One common use of the
fieldset and legend elements is a question with radio-button options for answers. The question text and radio
buttons are wrapped in a fieldset, with the question itself being inside the legend tag.</li>
<li><strong>Embed multiple fieldsets and legends for more complex forms.</strong></li>
<li><strong>Use simple vertical layouts.</strong> Keep your form blocks in a vertical pattern. This approach is
ideal, from an accessibility standpoint, because of limited vision that makes it hard to scan from right to left.
</li>
</ul>
<h2 id="identifying-required-fields">Identifying required fields</h2>
<ul class="usa-content-list">
<li><strong>Show whether a field is required or optional.</strong> Mark required fields as required by using a red
asterisk (<abbr title="required" class="usa-hint--required">*</abbr>).</li>
<li><strong>Use text descriptions.</strong> Combine red asterisks (<abbr title="required"
class="usa-hint--required">*</abbr>) with a text description at the top of the form instructing the user of its
meaning. <br />
<em>Example:</em> “A red asterisk (<abbr title="required" class="usa-hint--required">*</abbr>) indicates a
required field.”
</li>
<li><strong>Use the <code>required</code> attribute.</strong> Add the <code>required</code> attribute to your form
elements to indicate that a field must be filled out before submitting the form.</li>
<li><strong>Mark optional fields as "optional."</strong> Label optional fields with the word “optional” placed in
parentheses. <br />
<em>Example:</em> (optional)
</li>
<li><strong>Let users know if there is an error.</strong> Use a message or <a
href="{{ site.baseurl }}/components/alert">alert</a> to notify the user if a field that is required was not
completed, and indicate which field was not completed. Additionally, include an error notification in the page
title (<code>title</code> element) for screen readers.</li>
<li><em><strong>Note:</strong> One-field forms are the exception and do not need to be marked with a required label or symbol.</em>
</li>
</ul>

<h2 id="known-issues-with-screen-readers">Known issues with screen readers</h2>
<ul class="usa-content-list">
<li>VoiceOver on iOS currently does not support fieldset and legend elements for forms. You can address this issue
by using <code>aria-labelledby="for-attribute-of-label id-of-legend id-of-additional-info"</code> on each input in
the fieldset. Using <code>aria-labelledby</code> will overwrite the default text read by the screen reader, so it
is important to include all relevant information.</li>
<li>
VoiceOver on OS X offers partial support for <code>aria-describedby</code>. There's full support for conveying
description on text inputs, partial support for description changes when the text input is in focus, and no
support for <code>role="alert"</code>. Visit <a
href="https://a11ysupport.io/tech/aria/aria-describedby_attribute">a11ysupport.io</a> to view the full status of
support.</li>
</ul>
<div class="site-note"><strong>Note:</strong> These components have been designed to support a wide range of screen
readers, but they may not work with all versions.</div>
</section>
4 changes: 2 additions & 2 deletions _templates/form-templates/form-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ subnav:
- text: Latest updates
href: '#changelog'
changelog:
key: template-form
key: component-form
---

{% include accessibility.html %}
{% include forms-guidance.html %}
4 changes: 4 additions & 0 deletions css/_uswds-theme-custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ img {
@include typeset("lang");
}

abbr[title="required"] {
text-decoration: none;
}

// ========================================
// 2. Site layout
// ----------------------------------------
Expand Down