InputGroup
Place addons and actions around a native text control.
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.
Basic usage#
Playground#
Anatomy#
Place Leading parts before one Input or Textarea, then Trailing parts. The final internal frame paints the shared boundary.
Usage#
Direction and orientation#
In horizontal groups, 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 while keeping the same layout role. In horizontal groups it uses smaller inline padding; in vertical groups it uses smaller padding on all sides. This is useful for compact buttons, keyboard shortcuts, inline prefixes or suffixes, and other addons that need less surrounding space.
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 remains on the native Input or Textarea, and the native control’s variant applies when it is outside a group.
Size precedence is the control’s explicit size, group size, Field size, then theme defaults. classes.leading, classes.trailing, and their style 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. Clicking non-interactive group space focuses the native control; buttons and links retain their own focus behavior.
Examples#
Icon#
Place one or more icons in either horizontal part.
Text#
Supporting content accepts plain text and JSX without a dedicated text component.
Button#
Use the existing Button component for copy, toggle, and submit actions. Add compact to the containing part when the button should use denser surrounding padding; keep each button’s state and disabled behavior explicit.
Kbd#
Use Kbd to show a shortcut without changing the input’s keyboard behavior. Add compact to the containing part when the shortcut should use denser surrounding padding.
Dropdown#
DropdownMenu.Trigger can render as a button inside either horizontal part.
Spinner#
Render a loading icon explicitly wherever progress needs to appear.
Textarea#
Set orientation="vertical" to form a toolbar and status bar around the independent Textarea.
Auto-resize#
Textarea keeps its own value, ref, native attributes, and autoresize behavior. The same group can provide header and footer regions.
RTL#
Horizontal Leading and Trailing positions follow the inherited dir; vertical positions remain above and below the control.
Attributes#
data-input-groupSlot: input-groupDescription: Identifies a control rendered within an input group.data-orientationSlot: input-group, input-group-leading, input-group-trailingDescription: Stores the rendered orientation (horizontal or vertical).data-compactSlot: input-group-leading, input-group-trailingDescription: Present when the component uses its compact presentation.Props#
InputGroup#
Renders a <div> element by default.
Leading#
Renders a <div> element by default.
Trailing#
Renders a <div> element by default.