Form item

Wraps an input control with a text label, requirement label, helper text, and error text.

Props

error
string | React.ReactNode
Error text displayed under the form field. Leave blank to indicate a valid field. Accepts a string or ReactNode for custom error content.
helpText
string | React.ReactNode
Help text displayed under the form field to provide additional explanation. Accepts a string or ReactNode for custom help content.
id
string
Sets the id attribute on the form item element.
label
string
Creates a label for the form item.
labelSize
GoabFormItemLabelSize
Sets the label size. 'regular' for standard, 'large' for emphasis.
Defaults to regular.
maxWidth
string
Sets the maximum width of the form item.
Defaults to none.
name
string
Overrides the label value within the form-summary to provide a shorter description. For public-form use only.
requirement
GoabFormItemRequirement
Marks the field with an optional or required label indicator.
testId
string
Sets a data-testid attribute for automated testing.
type
GoabFormItemType
Specifies the input type for appropriate message spacing. Used with checkbox-list or radio-group.
mt, mr, mb, ml
Spacing
Apply margin to the top, right, bottom, and/or left of the component.
error
string | TemplateRef<any>
Error text displayed under the form field. Leave blank to indicate a valid field.
helpText
string | TemplateRef<any>
Help text displayed under the form field to provide additional explanation.
id
string
Sets the id attribute on the form item element.
label
string
Creates a label for the form item.
labelSize
GoabFormItemLabelSize
Sets the label size. 'regular' for standard, 'large' for emphasis.
maxWidth
string
Sets the maximum width of the form item.
name
string
Overrides the label value within the form-summary to provide a shorter description. For public-form use only.
requirement
GoabFormItemRequirement
Marks the field with an optional or required label indicator.
testId
string
Sets the data-testid attribute for automated testing.
type
GoabFormItemType
Specifies the input type for appropriate message spacing. Used with checkbox-list or radio-group.
mt, mr, mb, ml
Spacing
Apply margin to the top, right, bottom, and/or left of the component.
error
string
Error text displayed under the form field. Leave blank to indicate a valid field.
helptext
string
Help text displayed under the form field to provide additional explanation.
label
string
Creates a label for the form item.
labelsize
GoabFormItemLabelSizeType compact | regular | large
Sets the label size. 'compact' for dense layouts, 'regular' for standard, 'large' for emphasis.
Defaults to regular.
maxwidth
string
Sets the maximum width of the form item.
Defaults to none.
name
string
Overrides the label value within the form-summary. For public-form use only.
Defaults to blank.
requirement
GoabFormItemRequirementType optional | required
Marks the field with an optional or required label indicator.
testid
string
Sets a data-testid attribute for automated testing.
type
GoabFormItemInputType text-input | textarea | checkbox-list | radio-group
Specifies the input type for appropriate message spacing. Used with checkbox-list or radio-group.
version
GoabFormItemVersionType 1 | 2
Design system version for styling.
Defaults to 1.
mt, mr, mb, ml
Spacing
Apply margin to the top, right, bottom, and/or left of the component.

ReactNode

error
ReactNode
Error text displayed under the form field. Leave blank to indicate a valid field. Accepts a string or ReactNode for custom error content.
helpText
ReactNode
Help text displayed under the form field to provide additional explanation. Accepts a string or ReactNode for custom help content.
error
TemplateRef
Error text displayed under the form field. Leave blank to indicate a valid field. Accepts a string or ngTemplate for custom error content.
helpText
TemplateRef
Help text displayed under the form field to provide additional explanation. Accepts a string or ngTemplate for custom help content.
error
slot
Error text displayed under the form field. Leave blank to indicate a valid field. Accepts a string or ReactNode for custom error content.
helptext
slot
Help text displayed under the form field to provide additional explanation. Accepts a string or ReactNode for custom help content.
Examples

Add a record using a drawer

Add and edit lots of filters

Add another item in a modal

Ask a long answer question with a maximum word count

Ask a user for a birthday

The date picker component handles accessibility automatically. Ensure the form-item label clearly describes what date is being requested.

Ask a user for an address

Ask a user for an Indian registration number

Ask a user for direct deposit information

Ask a user for dollar amounts

Confirm a change

Disabled button with a required field

Dynamically add an item to a dropdown list

Dynamically change items in a dropdown list

Filter a list using a push drawer

Filter data in a table

Include descriptions for items in a checkbox list

Question page

Question page preview
More info

Reset date picker field

Reveal input based on a selection

Review and action

Select one or more from a list of options

Set a max width on a long radio item

Slotted error text in a form item

Slotted helper text in a form item

Type to create a new filter

Other

The form item automatically associates the label with the input for screen readers, ensuring your form is accessible.

Use a form item wrapper on all inputs to add a label, helper text, error message, and more.

Sizing

Use labelSize='large' when you want the question to act as the heading on the page. This is often the right choice when there's only one question on a page, so you don't end up with a separate heading and a question saying the same thing.

Forms

Don't use the character counter for input fields where user entries typically have standard or predictable lengths.
Use the character count only when there's a valid reason to limit the number of characters.
Make empty text areas as tall as the content they are expected to contain.
Ensure that the text area width is no longer than 75 characters per line; ideal line length is 45-75 characters.
Don't use a text area which is only one line high; instead, use text input if just one line is needed.
If you suggest a specific length for an answer to a question, display a word count to help guide the user.
All GoA Design System components are built to meet WCAG 2.2 AA standards. The following guidelines provide additional context for accessible implementation.

No accessibility-specific guidelines have been documented for this component yet.

View old component docs