InputGroup
Visual composition of several inputs and addons.
Installation
npx axiom add input-grouppnpm dlx axiom add input-groupyarn dlx axiom add input-groupbun x axiom add input-groupAlso copies input, whose tokens draw the group border and text, and button.
What it does
InputGroup places inputs and addons (a currency label, a unit, a button) side by side so they read as one field. The group draws the border; the inputs inside drop theirs.
Usage
import { InputGroup } from "@/components/ui/input-group";
<InputGroup>
<InputGroup.Addon>https://</InputGroup.Addon>
<InputGroup.Input placeholder="example.com" />
</InputGroup>;Props
InputGroup
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | β | Any mix of InputGroup.Input, InputGroup.Addon and InputGroup.Button. |
size | 'sm' | 'md' | 'lg' | 'md' | Minimum height of the whole group, 32, 44 or 52pt; children follow it. Grows with larger system text. |
error | boolean | false | Red border around the whole group. |
disabled | boolean | false | Disables every input and button in the group. |
divided | boolean | true | Draws a separator between adjacent parts. |
style | StyleProp<ViewStyle> | β | Extra styles for the container. |
The focused border is drawn around the whole group as soon as one of its inputs has focus.
InputGroup.Input
Every Input prop except label, helper, error and size, which belong to the group or the surrounding form.
| Prop | Type | Default | Description |
|---|---|---|---|
flex | number | 1 | Share of the remaining width. Two inputs with flex={1} and flex={2} split it one third / two thirds. |
disabled | boolean | false | Disables this input only. The groupβs disabled disables all of them. |
Without a visible label, set accessibilityLabel; the placeholder is used otherwise.
InputGroup.Addon
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | β | Static text or an icon. |
onPress | () => void | β | Makes the addon pressable, for example to open a country picker. |
variant | 'subtle' | 'plain' | 'subtle' | subtle fills the addon with inputGroup.default.default.addon, plain leaves it transparent. |
accessibilityLabel | string | text content | Announced when the addon is pressable. |
InputGroup.Button
A Button with its radius and border removed so it sits flush in the group. Same props as Button, except size, fullWidth and asChild: the size follows the group.
Use cases
Phone number with a country picker
The addon is pressable and opens a BottomSheet with the list of countries.
<InputGroup size="lg">
<InputGroup.Addon onPress={openCountries}>
{country.flag} {country.dialCode}
</InputGroup.Addon>
<InputGroup.Input
keyboardType="phone-pad"
autoComplete="tel"
value={phone}
onChangeText={setPhone}
/>
</InputGroup>Field with an inline action
A button inside the group for an action that only concerns this value: copy, apply, send.
<InputGroup>
<InputGroup.Input
autoCapitalize="characters"
value={code}
onChangeText={setCode}
/>
<InputGroup.Button variant="ghost" onPress={applyCode}>
Apply
</InputGroup.Button>
</InputGroup>Two inputs as one field
A range, or an expiry date and a CVC: separate values the user reads as one line.
<InputGroup>
<InputGroup.Input placeholder="MM / YY" keyboardType="number-pad" />
<InputGroup.Input
placeholder="CVC"
keyboardType="number-pad"
secureTextEntry
/>
</InputGroup>