InputGroup
Place addons and actions around a native text control.
Anatomy#
Place Leading parts before one Input or Textarea, then Trailing parts. The final frame element paints the shared boundary.
Usage#
Use InputGroup when an editable control and its addons share one visual boundary. Render a single Input or Textarea as a direct child; the control still owns text entry and its accessible name.
InputGroup.Leading and InputGroup.Trailing must render inside an InputGroup, and each renders a div unless as is set.
Direction and orientation#
In horizontal groups (the default), Leading and Trailing follow the document writing direction. In vertical groups, they sit above and below the control.
Configure inputGroup.defaultVariants.orientation in your Theme to change the shared default, or inputGroup.variants.orientation to override its styles.
Compact#
Set compact on Leading or Trailing to reduce its padding (inline padding in horizontal groups, all sides in vertical groups). Use it for icon buttons, keyboard shortcuts, and inline prefixes.
Styling and forms#
- Shared frame:
InputGroupowns the border, background, radius, and focus/invalid frame viasizeandvariant. The control’s ownvariantapplies only outside a group, while disabled state stays on the control. - Size and slot precedence: size resolves from the control’s explicit
size, groupsize,Fieldsize, then theme defaults.classes.leading/classes.trailingandstylesset group-wide presentation; each part’sclassandstyleoverride them. - Form and focus: keep
name,value,onValueChange,required,disabled,readOnly, and ARIA attributes on the control (InputGroupdoes not register a form field). Clicking non-interactive group space focuses the control, while buttons and links keep their own focus behavior.
Examples#
Icons#
Place icons in Leading or Trailing. The inner input keeps the accessible name.
Text addons#
Supporting content accepts plain text and JSX. No dedicated text part is required.
Actions#
Use Button for copy, toggle, and submit. Add compact on the part when an icon-only button needs
less padding, and keep an aria-label on that button. Set each button’s state and disabled
behavior explicitly.
Keyboard shortcut#
Show a shortcut with Kbd or KbdGroup. It does not change the input’s keyboard behavior.
Dropdown#
Render DropdownMenu.Trigger as a button inside Leading or Trailing.
Spinner#
Render a loading icon where progress should appear. InputGroup has no loading state.
Vertical#
Set orientation="vertical" for a header and status bar around an independent Textarea.
Textarea#
Textarea keeps its own value, ref, native attributes, and autoresize. The same group can hold header and footer regions.
RTL#
Horizontal Leading and Trailing follow the inherited dir. Vertical positions stay above and
below the control.
API Reference#
Attributes#
data-input-groupdata-orientationdata-compactProps#
InputGroup#
Renders a <div> element by default.
Leading#
Renders a <div> element by default.
Trailing#
Renders a <div> element by default.