Input
An input is where I provide a short answer to a question in an online form.
The Input component is the most common form component for receiving user information on an online form. There are several types of inputs (text being one of them) that suggest the type of information they can receive. Input types are enhanced with icon prefixes, postfixes, or masks to help users enter the correct information. They are always paired with a label inside a Form group component.
Details
- Extends: USWDS Text input component
- Customization: Styles
- Modifier:
.cfa-input
,.cfa-input-group
The Input extends the USWDS Text input component. Further customization is applied using the CSS modifier(s) .cfa-input
, .cfa-input-group
to add styles defined in a custom stylesheet.
Modifier. A modifier is a class name that applies a variant, type, or extended style customization to modify the component's visual appearance.
Examples
Guidance
Inputs vs. Textareas. When longer form content needs to be entered the textarea component is used.
Form groups. Form questions with input components always use the form group component to wrap the input with a visible label
element.
Refer to additional guidance on the USWDS documentation site.
USWDS documentation siteAdditional references
Accessibility
Refer to additional accessibility guidance on the USWDS documentation site.
Checklist Key
Design library component
Source and usage
- Sass stylesheet:
./_cfa-input.scss
- Thymeleaf template fragment:
./cfa-input.th.html
- Embedded Ruby (ERB) partial template:
./_cfa-input.html.erb
- JavaScript
is used to provide a formatting (mask) utility for U.S. Dollars, U.S. Phone, and Social Security Number input types.
Guidance on individual module loading will added. Currently, there is one script that imports all modules. The source is located at
@codeforamerica/js/index.js
. This entrypoint is compiled using Rollup.js and distributed to@codeforamerica/dist/js/default.js
.