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 should share one visual boundary. The inner
Input or Textarea still owns text entry and its
accessible name. Render the control as a direct child of InputGroup. InputGroup.Leading and
InputGroup.Trailing throw when rendered outside an InputGroup, and each renders a div unless you
set as.
Direction and orientation#
In horizontal groups (the default), Leading and Trailing follow the document’s writing direction.
In vertical groups, they sit above and below the control. Set inputGroup.defaultVariants.orientation
in your Theme to change the shared default, or inputGroup.variants.orientation to override its
styles.
Compact#
Set compact on a Leading or Trailing part to reduce its padding. In horizontal groups it
uses smaller inline padding; in vertical groups it uses smaller padding on all sides. Use it for
icon buttons, keyboard shortcuts, and inline prefixes.
Styling and forms#
InputGroup owns the shared border, background, radius, and focus/invalid frame. Set its size
and variant to style the group. Disabled presentation stays on the native Input or Textarea,
and the control’s own variant applies only outside a group.
Size precedence is the control’s explicit size, group size, Field size, then theme defaults.
classes.leading, classes.trailing, and their styles equivalents set group-wide presentation;
each part’s class and style override it.
Keep name, value, onValueChange, required, disabled, readOnly, and ARIA attributes on
the control. InputGroup does not register a form field. Pressing non-interactive group space
focuses the control; buttons, links, and other interactive elements keep their own focus behavior.
Examples#
Search, email, and card fields#
Place icons in Leading or Trailing. The inner input keeps the accessible name.
Price, URL, and username addons#
Supporting content accepts plain text and JSX. No dedicated text part is required.
Copy a profile URL#
Use Button for copy, toggle, and submit. Add compact on the part when the button needs less
padding. Set each button’s state and disabled behavior explicitly.
Clear a website URL#
Set compact on Trailing so an icon-only clear button fits the field. Keep aria-label on the
button.
Hint a command shortcut#
Show a shortcut with Kbd or KbdGroup. It does not change the input’s keyboard behavior.
File actions and scoped search#
Render DropdownMenu.Trigger as a button inside Leading or Trailing.
Show an in-progress lookup#
Render a loading icon where progress should appear. InputGroup has no loading state.
Edit source with a toolbar#
Set orientation="vertical" for a header and status bar around an independent Textarea.
Compose a comment#
Textarea keeps its own value, ref, native attributes, and autoresize. The same group can hold header and footer regions.
Search in 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.