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.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.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.A text input is used to gather free-form text from a user.