Package org.patternfly.component.form
package org.patternfly.component.form
Provides form components for building structured data entry interfaces.
This package contains the Form component and its sub-components for
creating accessible, validated forms. Forms organize input controls into groups with labels, helper text, and
validation feedback. The package includes text inputs, text areas, form selects, checkboxes, and radio buttons.
Components
Checkbox- Checkbox controlCheckboxBody- Body content area of a checkboxCheckboxDescription- Description text for a checkboxForm- Top-level form containerFormActionGroup- Contains form action buttons (submit, cancel)FormAlert- Displays an alert within a formFormControl- Base class for form controls with validation supportFormFieldGroup- Nestable field group with header and bodyFormFieldGroupBody- Body area of a form field groupFormFieldGroupHeader- Header area of a form field group with title and actionsFormGroup- Groups a label with a control and helper textFormGroupControl- Control area within a form groupFormGroupLabel- Label for a form groupFormGroupRole- Enumeration of form group ARIA roles (radiogroup, group)FormSection- Groups related form groups under a headingFormSelect- Native select dropdownFormSelectOption- Individual option within a form selectFormSelectOptionGroup- Option group within a form selectRadio- Radio button controlRadioBody- Body content area of a radio buttonRadioDescription- Description text for a radio buttonTextArea- Multi-line text inputTextAreaResize- Enumeration of text area resize optionsTextInput- Single-line text inputTextInputType- Enumeration of text input types (text, email, password, etc.)
Usage
A basic form with text inputs, checkboxes, and action buttons:
import static org.patternfly.component.button.Button.button;
import static org.patternfly.component.form.Checkbox.checkbox;
import static org.patternfly.component.form.Form.form;
import static org.patternfly.component.form.FormActionGroup.formActionGroup;
import static org.patternfly.component.form.FormGroup.formGroup;
import static org.patternfly.component.form.FormGroupControl.formGroupControl;
import static org.patternfly.component.form.FormGroupLabel.formGroupLabel;
import static org.patternfly.component.form.FormGroupRole.radiogroup;
import static org.patternfly.component.form.Radio.radio;
import static org.patternfly.component.form.TextInput.textInput;
import static org.patternfly.component.form.TextInputType.email;
import static org.patternfly.component.help.HelperText.helperText;
Form form = form()
.addGroup(formGroup("name").required()
.addLabel(formGroupLabel("Full name"))
.addControl(formGroupControl()
.addControl(textInput("name"))
.addHelperText(helperText("Include your middle name if you have one."))))
.addGroup(formGroup("email").required()
.addLabel(formGroupLabel("Email"))
.addControl(formGroupControl()
.addControl(textInput(email, "email"))))
.addGroup(formGroup("timezone").role(radiogroup)
.addLabel(formGroupLabel("Timezone"))
.addControl(formGroupControl().inline()
.addRadio(radio("tz-0", "timezone", "Eastern"))
.addRadio(radio("tz-1", "timezone", "Central"))
.addRadio(radio("tz-2", "timezone", "Pacific"))))
.addActionGroup(formActionGroup()
.addButton(button("Submit").primary())
.addButton(button("Cancel").link()));
- See Also:
-
ClassDescriptionA checkbox is used to select a single item or multiple items, typically to choose elements to perform an action or to reflect a binary setting.The body content of a
Checkboxcomponent.A description label for aCheckboxcomponent.A form is a group of elements used to collect information from a user in a variety of contexts, including in a modal, in a wizard, or on a page.A group of action buttons at the bottom of aFormcomponent.An alert message displayed within aFormcomponent.A wrapper for form control elements such as inputs, selects, and text areas within aForm.A group of related form fields within aFormcomponent.The body content area of aFormFieldGroup.The header area of aFormFieldGroup, typically containing a title and description.A container that groups a label, control, and helper text within aForm.The control area within aFormGroup, containing the actual input element.The label area within aFormGroup, containing the field label and optional help.Defines the ARIA role applied to aFormGroup.A titled section within aFormthat groups related form groups.A form select embeds browser native select lists into a form.An individual option within aFormSelectdropdown.A group of related options within aFormSelectdropdown.A radio button is used to present the user with mutually exclusive choices.The body content of aRadiocomponent.A description label for aRadiocomponent.A text area component is used for entering a paragraph of text that is longer than one line.Defines the resize directions available for aTextArea.A text input is used to gather free-form text from a user.Defines the HTML input types available for aTextInput.