Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.docs.components.Form.examples.Form.md Maven / Gradle / Ivy
---
id: Form
section: components
subsection: forms
cssPrefix: pf-v6-c-form
---## Examples
### Vertically aligned labels
```html
```
### Horizontally aligned labels
```html
```
### Horizontal layout at a custom breakpoint
```html
```
### Form sections
```html
```
### Help text
```html
```
### Label with additional info
```html
```
### Label with additional info (horizontal form)
```html
```
### Action group
```html
```
### Field group (non-expandable)
```html
```
### Expandable and nested field groups
```html
```
## Documentation
To avoid the form label's required indicator or help tooltip icon from wrapping separately from the form label text, all whitespace characters between the last word of the label text, the required indicator (`.pf-v6-c-form__label-required`), and help tooltip icon (`.pf-v6-c-form__label-help`) must be removed, and ` ` characters added in between to maintain spacing. Also the help tooltip icon's `.pf-v6-c-form__label-required` element must be a `` instead of a `` due to layout limitations of the `` element imposed by user agent styles.
### Accessibility
| Attribute | Applied to | Outcome |
| -- | -- | -- |
| `for` | `` | Each `` must have a `for` attribute that matches its form field id. **Required** |
| `id` | ` `, ``, `` | Each `` field must have an `id` attribute that matches its label's `for` value. **Required** |
| `required` | ` `, ``, `` | Required fields must include these attributes. |
| `aria-describedby="{helper_text_id}"` | ` `, ``, `` | Form fields with related `.pf-v6-c-helper-text` require this attribute. Usage ` `. |
| `aria-invalid="true" aria-describedby="{helper_text_id}"` | ` `, ``, `` | When form validation fails `aria-describedby` is used to communicate the error to the user. These attributes need to be handled with Javascript so that `aria-describedby` only references help text that explains the error, and so that `aria-invalid="true"` is only present when validation fails. For proper styling of errors `aria-invalid="true"` is required. |
| `aria-hidden="true"` | `.pf-v6-c-form__label-required` | Hides the required indicator from assistive technologies. |
| `role="group"` | `.pf-v6-c-form__group`, `.pf-v6-c-form__section`, `.pf-v6-c-form__field-group` | Provides group role for form groups, form sections, and form field groups. **Required for checkbox groups, form groups, form sections, and form field groups.** |
| `role="radiogroup"` | `.pf-v6-c-form__group` | Provides group role for radio input groups. **Required for radio input groups** |
| `role="button"` | `.pf-v6-c-form__group-label-help` | Provides button role for group label help spans. **Required for group label help.** |
| `id` | `.pf-v6-c-form__group-label` | Generates an `id` for use in the `aria-labelledby` attribute in a checkbox or radio form group. |
| `id` | `.pf-v6-c-form__field-group-title-text` | Generates an `id` for use in the `aria-labelledby` attribute in an expandable field group's toggle button. |
| `id` | `.pf-v6-c-form__field-group-toggle-button > button` | Generates an `id` for use in the `aria-labelledby` attribute in an expandable field group's toggle button. |
| `aria-labelledby="{label id}"` | `.pf-v6-c-form__group`, `.pf-v6-c-form__section`, `.pf-v6-c-form__field-group` | Provides an accessible label for form groups, form sections, and form field groups. **Required for form groups, form sections, and form field groups that contain labels.** |
| `aria-label` | `.pf-v6-c-form__field-group-toggle-button > button` | Provides an accessible label for the field group toggle button. |
| `aria-labelledby="{title id} {toggle button id}"` | `.pf-v6-c-form__field-group-toggle-button > button` | Provides an accessible label for the field group toggle button. |
| `aria-expanded="true/false"` | `.pf-v6-c-form__field-group-toggle-button > button` | Indicates whether the field group body is visible or hidden. |
| `id="{form_label_id}"` | `.pf-v6-c-form__label` | Generates an `id` for use in the `aria-describedby` attribute in a `.pf-v6-c-form__group-label-help`. |
| `aria-label="{descriptive text}" aria-describedby="{form_label_id}"` | `.pf-v6-c-form__group-label-help` | Provides an accessible label on a button that provides additional information for a form element. |
### Usage
| Class | Applied to | Outcome |
| -- | -- | -- |
| `.pf-v6-c-form` | `` | Initiates a standard form. **Required** |
| `.pf-v6-c-form__section` | `,
` | Initiates a form section. |
| `.pf-v6-c-form__section-title` | ``,``,``,``,``,``, `` | Initiates a form section title. |
| `.pf-v6-c-form__group` | `
` | Initiates a form group. |
| `.pf-v6-c-form__group-label` | `
` | Initiates a form group label. |
| `.pf-v6-c-form__label` | `
`, `` | Initiates a form label. **Required** |
| `.pf-v6-c-form__label-text` | `` | Initiates a form label text. **Required** |
| `.pf-v6-c-form__label-required` | `` | Initiates a form label required indicator. |
| `.pf-v6-c-form__group-label-main` | `` | Initiates a form group label main container. |
| `.pf-v6-c-form__group-label-info` | `
` | Initiates a form group info label. |
| `.pf-v6-c-form__group-label-help` | `
` | Initiates field level help. |
| `.pf-v6-c-form__group-control` | `` | Initiates a form group control section. |
| `.pf-v6-c-form__actions` | `
` | Iniates a row of actions. |
| `.pf-v6-c-form__helper-text` | `
`, `
` | Initiates a form helper text block. |
| `.pf-v6-c-form__alert` | `
` | Initiates the form alert container for inline alerts. |
| `.pf-v6-c-form__field-group` | `
` | Initiates a form field group. |
| `.pf-v6-c-form__field-group-toggle` | `
` | Initiates the form field group toggle. |
| `.pf-v6-c-form__field-group-toggle-button` | `
` | Initiates the form field group toggle button. |
| `.pf-v6-c-form__field-group-toggle-icon` | `
` | Initiates the form field group toggle icon. |
| `.pf-v6-c-form__field-group-header` | `` | Initiates the form field group header. |
| `.pf-v6-c-form__field-group-header-main` | `
` | Initiates the form field group main section. |
| `.pf-v6-c-form__field-group-header-title` | `
` | Initiates the form field group title. |
| `.pf-v6-c-form__field-group-header-title-text` | `
` | Initiates the form field group title text. |
| `.pf-v6-c-form__field-group-header-description` | `
` | Initiates the form field group description. |
| `.pf-v6-c-form__field-group-header-actions` | `
` | Initiates the form field group actions container. |
| `.pf-v6-c-form__field-group-body` | `
` | Initiates the form field group body. |
| `.pf-m-horizontal{-on-[xs, sm, md, lg, xl, 2xl]}` | `.pf-v6-c-form` | Modifies the form for a horizontal layout at an optional breakpoint. The default breakpoint is `-md`. |
| `.pf-m-limit-width` | `.pf-v6-c-form` | Limits the overall max-width of the form. Configurable by defining `--pf-v6-c-form--m-limit-width--MaxWidth`. |
| `.pf-m-info` | `.pf-v6-c-form__group-label` | Modifies the form group label to contain form group label info. |
| `.pf-m-action` | `.pf-v6-c-form__group` | Modifies form group margin-top. |
| `.pf-m-disabled` | `.pf-v6-c-form__label` | Modifies form label to show disabled state. |
| `.pf-m-no-padding-top` | `.pf-v6-c-form__group-label` | Removes top padding from the label element for labels adjacent to an element that isn't a form control. |
| `.pf-m-inline` | `.pf-v6-c-form__group-control` | Modifies form group children to be inline (this is primarily for radio buttons and checkboxes). |
| `.pf-m-stack` | `.pf-v6-c-form__group-control` | Modifies form group children to be stacked with space between children. |
| `.pf-m-expanded` | `.pf-v6-c-form__field-group` | Modifies an expandable field group for the expanded state. |
| `--pf-v6-c-form--m-limit-width--MaxWidth` | `.pf-v6-c-form.pf-m-limit-width` | Sets a custom `max-width` for a width limited form. |