--- title: Form elements description: Form elements structures user inputs with labels, controls, and consistent spacing. --- ## Basics Wrap the form in `.env-form`. Each form field combination of text label and form control may optionally be wrapped in `.env-form-field` for consistent spacing. The form field wrapper may also contain a help text using `.env-form-field-help`. ```html

Form field help

``` ### Form control container The class `.env-form-control` creates a multipurpose container used to group and enhance form controls and related elements. Common elements used inside `.env-form-control` include: - `.env-form-label` - `.env-form-input` - `.env-button` - `.env-icon` - `.env-radio` - `.env-checkbox` - `.env-switch` #### Usages Create an [input group](#input-group) with a label, input and button using a combination of `.env-form-input`, `.env-button`, and `.env-form-label`. ```html
``` [Option elements](#option-elements), such as radio buttons, checkboxes and switches should use the wrapper together with a label for alignment and spacing. Use `.env-radio`, `.env-checkbox`, or `.env-switch` together with `.env-form-label`. ```html
``` Add [icons](#input-icons) to input fields using the combination of `.env-form-input` and `.env-icon`. ```html
``` ## Input elements ```html
``` ### Search input element Use `.env-form-input` and `[type="search"]` for search input elements. Add modifier class `.env-form-input--search` to display a clear button. ```html
``` ### Textarea element Use `.env-form-input` for a textarea element. Add `rows` attribute to specify the number of visible text lines. The textarea will be resizable vertically. ```html
``` ### Contenteditable element Make sure to add `role="textbox"` and `aria-multiline="true"` to the contenteditable element. The contenteditable element should also have `aria-label` or `aria-labelledby` attribute since a native label element is not allowed. An optional placeholder may be added using attribute `aria-placeholder` on the contenteditable element. ```html
Contenteditable
``` ## Select element and component **Updated in 2025.05.1.** With the introduction of [Customizable select elements](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select), both the Select element and the Select component support a progressively enhanced approach that applies as much of the Envision styling as possible while maintaining native select element functionality. This feature is opt-in and can be enabled by adding a `button` with a `selectedcontent` tag inside the select element. ### Select component A ` ``` ### Customizable select 2025.05.1 To opt in to the customizable version — which uses theme fonts, colors, and allows icons — add a `button` as the first child of the `select`, with a `selectedcontent` element inside the `button`. Use the `.env-icon` class to display icons in the options or in the selected value.
```html noexample
``` ### Select element Native select element with class `.env-form-input`. Only light styling, might look different in different browsers.
```html noexample
``` ## Option elements ### Radiobutton input element Related radiobutton elements should be wrapped by a fieldset element to indicate group membership of the contained elements. Use `.env-form-control` to wrap `.env-radio` and `.env-form-label. ```html
Radio button
``` ### Checkbox input element Related checkbox elements should be wrapped by a fieldset element to indicate group membership of the contained elements. Use `.env-form-control` to wrap `.env-checkbox` and `.env-form-label`. ```html
Checkbox
``` ### Switch component Use `.env-form-control` to wrap an `.env-switch` checkbox and `.env-form-label`. ```html
``` ## Range input element 2026.05.1 Use an input element with class `.env-range` and `[type="range"]`. For the deprecated two-handle component, see [Range slider](/deprecated/range-slider/). ```html
``` To display step markers below the input, add a `datalist` element and connect it to the input with the `list` attribute. The `datalist` must contain `option` elements with a `value` attribute. ```html
``` All elements with class `.env-range` and `[type="range"]` are automatically initialized on `DOMContentLoaded`. Range elements added to the DOM after the document has loaded must be initialized from script. ```javascript // Initialize range elements added after DOMContentLoaded envision.range(); ```
## Icons in input fields Use `.env-form-control` to wrap `.env-icon` and `.env-form-input`. ```html
``` ## Input group Wrap text, input and button with `.env-form-control` to create an input group. Use `.env-form-control` to wrap `.env-checkbox` and `.env-form-label`. ```html
``` ## States ### Disabled & Readonly Attribute `[disabled]` may be placed on form elements or fieldset elements to disable the form control(s). Attribute `[readonly]` is also available for input elements. ```html
Disabled radio button group
``` ## Validation error Add modifier `.env-form-field--error` to define error validation state. The `aria-describedby` attribute should be used to reference the `ID` of the text that describes the element. Error validation state uses the Status color [Error text](/colors/status-colors/). ```html

Error feedback

``` ## Deprecated [Deprecated legacy form classes and components can be found here](/deprecated/form/).