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
Form- Top-level form containerFormGroup- Groups a label with a control and helper textFormGroupLabel- Label for a form groupFormGroupControl- Control area within a form groupFormSection- Groups related form groups under a headingFormActionGroup- Contains form action buttons (submit, cancel)FormAlert- Displays an alert within a formFormFieldGroup- Nestable field group with header and bodyTextInput- Single-line text inputTextArea- Multi-line text inputFormSelect- Native select dropdownCheckbox- Checkbox controlRadio- Radio button control
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.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 form select embeds browser native select lists into a form.A radio button is used to present the user with mutually exclusive choices.A text area component is used for entering a paragraph of text that is longer than one line.A text input is used to gather free-form text from a user.