apps/docs/content/docs/native/components/(forms)/input-group.mdx
<NativeVideoPlayerView srcLight="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/native/components/videos/input-group-docs-light.mp4" srcDark="https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/docs/native/components/videos/input-group-docs-dark.mp4" />
import { InputGroup } from 'heroui-native';
<InputGroup>
<InputGroup.Prefix>...</InputGroup.Prefix>
<InputGroup.Input />
<InputGroup.Suffix>...</InputGroup.Suffix>
</InputGroup>
paddingLeft on InputGroup.Input automatically.paddingRight on InputGroup.Input automatically.The InputGroup component uses compound parts to attach prefix and suffix content to an input.
<InputGroup>
<InputGroup.Prefix>...</InputGroup.Prefix>
<InputGroup.Input placeholder="Enter text" />
<InputGroup.Suffix>...</InputGroup.Suffix>
</InputGroup>
Attach leading content such as icons to the input.
<InputGroup>
<InputGroup.Prefix isDecorative>
<PersonIcon size={16} />
</InputGroup.Prefix>
<InputGroup.Input placeholder="Username" />
</InputGroup>
Attach trailing content such as icons to the input.
<InputGroup>
<InputGroup.Input placeholder="Search products..." />
<InputGroup.Suffix isDecorative>
<MagnifierIcon size={16} />
</InputGroup.Suffix>
</InputGroup>
Set isDecorative on Prefix or Suffix to make touches pass through to the Input and hide the content from screen readers. Omit it when the decorator contains interactive elements.
<InputGroup>
<InputGroup.Prefix isDecorative>
<LockIcon size={16} />
</InputGroup.Prefix>
<InputGroup.Input placeholder="Enter your password" secureTextEntry />
<InputGroup.Suffix>
<Pressable onPress={togglePasswordVisibility}>
<EyeIcon size={16} />
</Pressable>
</InputGroup.Suffix>
</InputGroup>
Disable the entire input group. The disabled state cascades to all child components.
<InputGroup isDisabled>
<InputGroup.Prefix isDecorative>
<LockIcon size={16} />
</InputGroup.Prefix>
<InputGroup.Input placeholder="Disabled input" />
</InputGroup>
Combine with TextField, Label, and Description for full form field support.
<TextField isRequired>
<Label>Email</Label>
<InputGroup>
<InputGroup.Prefix isDecorative>
<MailIcon size={16} />
</InputGroup.Prefix>
<InputGroup.Input placeholder="[email protected]" keyboardType="email-address" />
</InputGroup>
<Description>We'll never share your email</Description>
</TextField>
import { InputGroup } from 'heroui-native';
import { Ionicons } from '@expo/vector-icons';
import { useState } from 'react';
import { Pressable, View } from 'react-native';
export default function InputGroupExample() {
const [value, setValue] = useState('');
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
return (
<View className="px-5">
<InputGroup>
<InputGroup.Prefix isDecorative>
<Ionicons name="lock-closed-outline" size={16} color="#888" />
</InputGroup.Prefix>
<InputGroup.Input
value={value}
onChangeText={setValue}
placeholder="Enter your password"
secureTextEntry={!isPasswordVisible}
/>
<InputGroup.Suffix>
<Pressable
onPress={() => setIsPasswordVisible(!isPasswordVisible)}
hitSlop={20}
>
<Ionicons
name={isPasswordVisible ? 'eye-off-outline' : 'eye-outline'}
size={16}
color="#888"
/>
</Pressable>
</InputGroup.Suffix>
</InputGroup>
</View>
);
}
You can find more examples in the GitHub repository.
| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Children elements to be rendered inside the input group |
className | string | - | Additional CSS classes |
isDisabled | boolean | false | Whether the entire input group and its children are disabled |
animation | AnimationRootDisableAll | - | Animation configuration for input group |
...ViewProps | ViewProps | - | All standard React Native View props are supported |
Animation configuration for the InputGroup root component. Can be:
"disable-all": Disable all animations including children (cascades down)undefined: Use default animations| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Content to render inside the prefix |
className | string | - | Additional CSS classes |
isDecorative | boolean | false | When true, touches pass through to the Input and content is hidden from screen readers |
...ViewProps | ViewProps | - | All standard React Native View props are supported |
| prop | type | default | description |
|---|---|---|---|
children | React.ReactNode | - | Content to render inside the suffix |
className | string | - | Additional CSS classes |
isDecorative | boolean | false | When true, touches pass through to the Input and content is hidden from screen readers |
...ViewProps | ViewProps | - | All standard React Native View props are supported |
Pass-through to the Input component. Accepts all Input props directly.