Input group
Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs.
Input groups attach add-on elements to a textual input field. Add-ons can be text, buttons, or button groups. Add labels, help text, and validation styles with form fields.
Pass htmlFor to InputGroupText to render the add-on itself as a label for its control.
<Stack gap={3}>
<InputGroup>
<InputGroupText id="basic-addon1">
@
</InputGroupText>
<FormControl
aria-describedby="basic-addon1"
aria-label="Username"
placeholder="Username"
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-describedby="basic-addon2"
aria-label="Recipient’s username"
placeholder="Recipient’s username"
type="text"
/>
<InputGroupText id="basic-addon2">
@example.com
</InputGroupText>
</InputGroup>
</Stack>Examples
Place one add-on or button on either side of a control, or add one to both sides. Place FormLabel outside InputGroup so the label remains associated with the control.
With form field
Wrap InputGroup in FormField to pair it with a label and description.
<FormField>
<FormLabel htmlFor="inputGroupField">
Your vanity URL
</FormLabel>
<InputGroup>
<InputGroupText>
<a href="https://example.com/">
https://example.com/
</a>
</InputGroupText>
<FormControl
id="inputGroupField"
placeholder="username"
type="text"
/>
</InputGroup>
<FormText>
Choose a unique URL for your profile.
</FormText>
</FormField>Buttons
Use buttons instead of addons for supporting interactive options.
<InputGroup>
<InputGroupButton
id="button-addon"
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<FormControl
aria-describedby="button-addon"
aria-label="Example text with button addon"
placeholder=""
type="text"
/>
</InputGroup>Textarea
Input groups adapt to the height of textarea elements.
<InputGroup>
<InputGroupText>
With textarea
</InputGroupText>
<FormTextArea aria-label="With textarea" />
</InputGroup>Select
<>
<InputGroup className="mb-3">
<InputGroupText htmlFor="inputGroupSelect01">
Options
</InputGroupText>
<FormSelect
defaultValue="Choose..."
id="inputGroupSelect01"
>
<option>
Choose...
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</InputGroup>
<InputGroup className="mb-3">
<FormSelect
defaultValue="Choose..."
id="inputGroupSelect02"
>
<option>
Choose...
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
<InputGroupText htmlFor="inputGroupSelect02">
Options
</InputGroupText>
</InputGroup>
<InputGroup className="mb-3">
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<FormSelect
aria-label="Example select with button addon"
defaultValue="Choose..."
id="inputGroupSelect03"
>
<option>
Choose...
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</InputGroup>
<InputGroup>
<FormSelect
aria-label="Example select with button addon"
defaultValue="Choose..."
id="inputGroupSelect04"
>
<option>
Choose...
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
</InputGroup>
</>File input
<>
<InputGroup className="mb-3">
<InputGroupText htmlFor="inputGroupFile01">
Upload
</InputGroupText>
<FormControl
id="inputGroupFile01"
type="file"
/>
</InputGroup>
<InputGroup className="mb-3">
<FormControl
id="inputGroupFile02"
type="file"
/>
<InputGroupText htmlFor="inputGroupFile02">
Upload
</InputGroupText>
</InputGroup>
<InputGroup className="mb-3">
<InputGroupButton
id="inputGroupFileAddon03"
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<FormControl
aria-describedby="inputGroupFileAddon03"
aria-label="Upload"
id="inputGroupFile03"
type="file"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-describedby="inputGroupFileAddon04"
aria-label="Upload"
id="inputGroupFile04"
type="file"
/>
<InputGroupButton
id="inputGroupFileAddon04"
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
</InputGroup>
</>Checkboxes and radios
Place any checkbox or radio within an input group’s addon instead of text.
<>
<InputGroup className="mb-3">
<InputGroupText>
<Checkbox aria-label="Checkbox for following text input" />
</InputGroupText>
<FormControl
aria-label="Text input with checkbox"
type="text"
/>
</InputGroup>
<InputGroup>
<InputGroupText>
<Radio aria-label="Radio button for following text input" />
</InputGroupText>
<FormControl
aria-label="Text input with radio button"
type="text"
/>
</InputGroup>
</>Multiple inputs
Although InputGroup can display multiple FormControl components, validation styles are available only when the group contains a single control.
<Stack gap={3}>
<InputGroup>
<FormControl
aria-label="First name"
type="text"
/>
<FormControl
aria-label="Middle name"
type="text"
/>
<FormControl
aria-label="Last name"
type="text"
/>
</InputGroup>
<InputGroup>
<InputGroupText>
First and last name
</InputGroupText>
<FormControl
aria-label="First name"
type="text"
/>
<FormControl
aria-label="Last name"
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-label="Username"
placeholder="Username"
type="text"
/>
<InputGroupText>
@
</InputGroupText>
<FormControl
aria-label="Server"
placeholder="Server"
type="text"
/>
</InputGroup>
</Stack>Multiple addons
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
<Stack gap={3}>
<InputGroup>
<InputGroupText>
$
</InputGroupText>
<InputGroupText>
0.00
</InputGroupText>
<FormControl
aria-label="Dollar amount (with dot and two decimal places)"
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-label="Dollar amount (with dot and two decimal places)"
type="text"
/>
<InputGroupText>
$
</InputGroupText>
<InputGroupText>
0.00
</InputGroupText>
</InputGroup>
<InputGroup>
<InputGroupText>
$
</InputGroupText>
<FormControl
aria-label="Amount (to the nearest dollar)"
type="text"
/>
<InputGroupText>
.00
</InputGroupText>
</InputGroup>
</Stack>Button addons
<Stack gap={3}>
<InputGroup>
<InputGroupButton
id="button-addon1"
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<FormControl
aria-describedby="button-addon1"
aria-label="Example text with button addon"
placeholder=""
type="text"
/>
</InputGroup>
<InputGroup className="mb-3">
<FormControl
aria-describedby="button-addon2"
aria-label="Recipient’s username"
placeholder="Recipient’s username"
type="text"
/>
<InputGroupButton
id="button-addon2"
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
</InputGroup>
<InputGroup className="mb-3">
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<FormControl
aria-label="Example text with two button addons"
placeholder=""
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-label="Recipient’s username with two button addons"
placeholder="Recipient’s username"
type="text"
/>
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Button
</InputGroupButton>
</InputGroup>
</Stack>Buttons with menus
<Stack gap={3}>
<InputGroup>
<InputGroupMenu
align="start"
label="Menu"
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action
</MenuItem>
<MenuItem href="#">
Another action
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
<FormControl
aria-label="Text input with menu button"
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-label="Text input with menu button"
type="text"
/>
<InputGroupMenu
align="end"
label="Menu"
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action
</MenuItem>
<MenuItem href="#">
Another action
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
</InputGroup>
<InputGroup>
<InputGroupMenu
align="start"
label="Menu"
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action before
</MenuItem>
<MenuItem href="#">
Another action before
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
<FormControl
aria-label="Text input with 2 menu buttons"
type="text"
/>
<InputGroupMenu
align="end"
label="Menu"
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action
</MenuItem>
<MenuItem href="#">
Another action
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
</InputGroup>
</Stack>Segmented buttons
<>
<InputGroup className="mb-3">
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Action
</InputGroupButton>
<InputGroupMenu
align="start"
label="Toggle Menu"
split
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action
</MenuItem>
<MenuItem href="#">
Another action
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
<FormControl
aria-label="Text input with segmented menu button"
type="text"
/>
</InputGroup>
<InputGroup>
<FormControl
aria-label="Text input with segmented menu button"
type="text"
/>
<InputGroupButton
theme="secondary"
type="button"
variant="outline"
>
Action
</InputGroupButton>
<InputGroupMenu
align="end"
label="Toggle Menu"
split
toggleProps={{
theme: 'secondary',
variant: 'outline'
}}
>
<MenuItem href="#">
Action
</MenuItem>
<MenuItem href="#">
Another action
</MenuItem>
<MenuItem href="#">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#">
Separated link
</MenuItem>
</InputGroupMenu>
</InputGroup>
</>Border radius
Sometimes an extra element needs to bypass the group's border-radius adjustments. Wrap that element in InputGroupIgnore to preserve its own border radius.
Consider this extra hidden input example:
<InputGroup>
<InputGroupText id="visible-addon">
@
</InputGroupText>
<FormControl
aria-describedby="visible-addon"
aria-label="Username"
placeholder="Username"
type="text"
/>
<InputGroupIgnore>
<FormControl
aria-describedby="visible-addon"
aria-label="Hidden input"
className="d-none"
placeholder="Hidden input"
type="text"
/>
</InputGroupIgnore>
</InputGroup>Sizing
Set the size prop on InputGroup to resize its contents; you do not need to repeat the size prop on each form control.
Sizing on the individual input group elements isn’t supported.
<Stack gap={3}>
<InputGroup size="sm">
<InputGroupText id="inputGroup-sizing-sm">
Small
</InputGroupText>
<FormControl
aria-describedby="inputGroup-sizing-sm"
aria-label="Sizing example input"
type="text"
/>
</InputGroup>
<InputGroup>
<InputGroupText id="inputGroup-sizing-default">
Default
</InputGroupText>
<FormControl
aria-describedby="inputGroup-sizing-default"
aria-label="Sizing example input"
type="text"
/>
</InputGroup>
<InputGroup size="lg">
<InputGroupText id="inputGroup-sizing-lg">
Large
</InputGroupText>
<FormControl
aria-describedby="inputGroup-sizing-lg"
aria-label="Sizing example input"
type="text"
/>
</InputGroup>
</Stack>CSS
Variables
.example {
--bs-input-group-addon-padding-y: var(--bs-btn-input-padding-y);
--bs-input-group-addon-padding-x: var(--bs-btn-input-padding-x);
--bs-input-group-addon-font-size: var(--bs-btn-input-font-size);
--bs-input-group-addon-line-height: var(--bs-btn-input-line-height);
--bs-input-group-addon-color: var(--bs-fg-body);
--bs-input-group-addon-bg: var(--bs-bg-2);
--bs-input-group-addon-border-color: var(--bs-border-color);
}