diff --git a/apps/website/src/components/docs-navigation.tsx b/apps/website/src/components/docs-navigation.tsx index 5232856..9214631 100644 --- a/apps/website/src/components/docs-navigation.tsx +++ b/apps/website/src/components/docs-navigation.tsx @@ -162,6 +162,11 @@ function getNavigationItems(locale: Locale): DocsNavigationItem[] { id: "components/form-input", title: "Form input", }, + { + href: localizedPath(locale, "/docs/components/form-input-group"), + id: "components/form-input-group", + title: "Form input group", + }, { href: localizedPath(locale, "/docs/components/form-password-input"), id: "components/form-password-input", diff --git a/docs/en/components/form-input-group.mdx b/docs/en/components/form-input-group.mdx new file mode 100644 index 0000000..f6c92cf --- /dev/null +++ b/docs/en/components/form-input-group.mdx @@ -0,0 +1,119 @@ +--- +title: Form input group +description: Combines a form control with related text, buttons, or a dropdown. +--- + +## Usage + +```tsx +import { GlFormInput } from "gitlab-ui-react/form-input"; +import { + GlFormInputGroup, + GlFormInputGroupAddon, + GlInputGroupText, +} from "gitlab-ui-react/form-input-group"; +``` + +```tsx + + + + @ + + + +``` + +## 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. + + + +## 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. + + + +## 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. + + + +## 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. + + + +## 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. + + + +## 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`. + + + +## 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. + + + +## Accessibility + +- Associate each input or select with a visible `