Form input group

Combines a form control with related text, buttons, or a dropdown.

On this page

This docs is LLM-friendly and available as clean Markdown.

Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more

Usage

import { GlFormInput } from "gitlab-ui-react/form-input";
import {
  GlFormInputGroup,
  GlFormInputGroupAddon,
  GlInputGroupText,
} from "gitlab-ui-react/form-input-group";
<GlFormInputGroup aria-label="Username">
  <GlFormInputGroupAddon position="prepend">
    <GlInputGroupText id="username-prefix">@</GlInputGroupText>
  </GlFormInputGroupAddon>
  <GlFormInput
    aria-label="Username"
    aria-describedby="username-prefix" />
</GlFormInputGroup>

Default

Compose a control explicitly inside GlFormInputGroup; the group does not create an input. Wrap a text prefix in GlFormInputGroupAddon and GlInputGroupText, and give the input a visible label.

Input with a text prefix
@

Text addons

Add text before or after an input to communicate a fixed prefix, suffix, or unit. Place a prepend addon before the control and an append addon after it in JSX: position selects the styling, and the group preserves child order. Keep controls and addon wrappers directly inside the group so their borders join correctly.

Text prefix and suffix
https://
.git

Button addons

Place a related action inside an addon without wrapping the button in GlInputGroupText. Set its type when it should submit or reset a form; GlButton defaults to type="button". This example uses the native form reset behavior to clear the search input.

Input with a clear button

Select control

Compose GlFormSelect when the value comes from a fixed list. Render it directly inside the group; its built-in wrapper handles the joined borders and flexible width.

Select with a text addon
Role

Range input

A range input can use text addons to show its bounds. Set type, min, and max on GlFormInput, and keep a visible label that describes the value being adjusted.

Range with visible bounds
0
100

States

Set readOnly, disabled, and validation state on the composed control. Set disabled separately on related actions when they should also be unavailable. A read-only input remains focusable and selectable; an invalid input needs visible feedback associated with aria-describedby.

Read-only, invalid, and disabled controls
https://
seconds
Enter a timeout of at least 1 second.

Predefined options

Compose a GlListbox inside an addon and control the input value in React to populate it from predefined options. Apply readOnly to the input when editing is unavailable, and call event.currentTarget.select() in its onClick handler to select the text. These behaviors are supplied by the composed components and event handler.

Predefined URLs and selection on click

Accessibility

  • Associate each input or select with a visible GlFormFieldLabel using matching htmlFor and id values. GlInputGroupText renders a div, so its text does not label a control automatically.
  • The root always renders role="group". Use aria-labelledby or aria-label to name the group; that name does not label its individual controls.
  • Reference meaningful prefixes, suffixes, units, and feedback from the control with aria-describedby.
  • Give every interactive addon its own accessible name. Icon-only buttons need aria-label.
  • Keep JSX order consistent with visual and keyboard focus order, and preserve visible focus indicators.
  • Pair state={false} on the input with an explanation of how to fix the value; the input sets aria-invalid automatically.

API

All three components forward supported div attributes and a ref to their rendered div. Input values, input events, validation, and disabled state belong to the composed controls.

GlFormInputGroup

Accepts children and native div attributes, except role. It renders children in the supplied order and always sets role="group".

GlFormInputGroupAddon

Prop Description Default
position Required. Selects prepend or append styling; it does not reorder children.

Accepts children for text, buttons, or a dropdown, plus native div attributes.

GlInputGroupText

Accepts children and native div attributes. Renders non-interactive text with the addon appearance; place it inside GlFormInputGroupAddon.