Form group
A form group contains one option or form field under one question.
The Form group component contains one form element such as an input, textarea, or select. The form element has a meaningful label associated with it. It may also contain an extra hint to help the user provide a valid answer.
Details
- Honeycrisp: Form group molecule
- Customization: Design tokens and Styles
- Modifier:
.cfa-form-group
,.cfa-label
,.cfa-hint
,.cfa-input-group
,.cfa-input
,.cfa-textarea
,.cfa-select
The Form group includes the text input component, textarea component, select component, and other components that do not have dedicated documentation in the USWDS (labels and hints). The visual appearance is modified using design tokens from the Honeycrisp Form elements atom and Form group molecule. Further customization is applied using the CSS modifiers .cfa-form-group
, .cfa-label
, .cfa-hint
, .cfa-input-group
, .cfa-input
, .cfa-textarea
, .cfa-select
to add styles defined in custom stylesheets.
Design tokens. Tokens define the name of basic system elements such as color, typography, or spacing. The values of tokens are relative to how the system defines them. This enables teams to alter the visual appearance of components yet remain within the system boundaries. Learn more about tokens on the Bixal's Design Tokens Guide.
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
Form groups vs. Fieldsets. Form questions with one form element, such as a text input, text area, or select, may use the form group component to associate the form element with a question (or label
element). Use the fieldset component to associate multiple form elements with the same question, such as multi-part text inputs, checkboxes, or radio buttons.
Text inputs. Refer to text input documentation.
Textareas. Refer to textarea documentation.
Select. Refer to select documentation.
Accessibility
Checklist Key
Design library component
Source and usage
- Sass stylesheet:
./_cfa-form-group.scss
- Thymeleaf template fragment:
./cfa-form-group.th.html
- Embedded Ruby (ERB) partial template:
./_cfa-form-group.html.erb
- JavaScript
provides custom input masking support utilizing the open source library Cleave.js.
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
.