On this page
InputGroup
Draws one field chrome around an Input and addons on either side, such as an icon, a prefix or a button. A click on a bare part of the group focuses the input.
Use for
- an input with a leading icon or prefix
- an input with a trailing button, such as show password or clear
Practices
| Guidance | Practice |
|---|---|
| Do | Use InputGroup.Input, so the input takes the group size and drops its own chrome. |
| Do | Put a Button in an addon without size or variant props. The addon sizes it as a square neutral ghost button to fit the group. |
| Don’t | Render InputGroup.Start or InputGroup.End outside InputGroup.Root. They throw. |
API reference
InputGroup.Root
A div that draws the chrome and carries data-size, data-disabled and data-invalid.
Slot: cl-input-group
| Prop | Type | Description |
|---|---|---|
size | InputGroupSize | sm, md or lg. The input and addon buttons follow it.Default: 'md' |
disabled | boolean | Disables the input and addon buttons.Default: the enclosing `Field`'s, else `false` |
invalid | boolean | Marks the input aria-invalid.Default: the enclosing `Field`'s, else `false` |
InputGroup.Input
The Input, as a ghost input sized by the group.
Slot: cl-input
InputGroup.Start
A span before the input. Sets the defaults for any Button inside it.
Slot: cl-input-group-start
InputGroup.End
A span after the input. Sets the defaults for any Button inside it.
Slot: cl-input-group-end
Examples
A search input
<InputGroup.Root>
<InputGroup.Start>
<Icon glyph={MagnifyingGlass} />
</InputGroup.Start>
<InputGroup.Input type='search' aria-label='Search' />
</InputGroup.Root>