Looking for documentation on gluestack-ui v2 with NativeWind? Refer to this link.
This is an illustration of a Themed Input component with default configuration.
variant
size
isDisabled
isInvalid
isReadOnly
<Input
variant="outline"
size="md"
isDisabled={false}
isInvalid={false}
isReadOnly={false}
>
<InputFieldplaceholder="Enter Text here"/>
</Input>
API Reference
Import
To use this component in your project, include the following import statement in your file.
import{ Input } from '@gluestack-ui/themed';
Anatomy
The structure provided below can help you identify and understand a Input component's various parts.
exportdefault()=>(
<Input>
<InputField/>
<InputSlot>
<InputIcon>{/* Some Icon Component */}</InputIcon>
</InputSlot>
</Input>
)
Component Props
This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.
Input
It inherits all the properties of React Native's View component.
Prop
Type
Default
Description
isInvalid
bool
false
When true, the input displays an error state.
isDisabled
bool
false
When true, the input is disabled and cannot be edited.
isHovered
bool
false
When true, the input displays a hover state.
isFocused
bool
false
When true, the input displays a focus state.
isRequired
bool
false
If true, sets aria-required="true" on the input.
isReadOnly
bool
false
If true, the input value cannot be edited.
Descendants Styling Props
Props to style child components.
Sx Prop
Description
_input
Prop to style InputField Component
_icon
Prop to style InputIcon Component
InputField
Contains all TextInput related layout style props and actions.
It inherits all the properties of React Native's TextInput component.
Prop
Type
Default
Description
type
'text' | 'password'
'text'
If true, the input component obscures the text entered so that sensitive text like passwords stay secure.
InputSlot
It inherits all the properties of React Native's Pressable component.
Descendants Styling Props
Props to style child components.
Sx Prop
Description
_icon
Prop to style InputIcon Component
InputIcon
Contains all Icon related layout style props and actions. It inherits all the properties of React Native's View component.
Features
Keyboard support for actions.
Support for hover, focus and active states.
Option to add your styles or use the default styles.
Accessibility
We have outlined the various features that ensure the Input component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards.Adheres to the WAI-ARIA design pattern.
Keyboard
Setting the aria-label and aria-hint to help users understand the purpose and function of the Input
Screen Reader
Compatible with screen readers such as VoiceOver and Talk-back.
The accessible and aria-label props to provide descriptive information about the Input
Setting aria-traits and aria-hint to provide contextual information about the various states of the Input, such as "double tap to edit".
Focus Management
The onFocus and onBlur props to manage focus states and provide visual cues to users. This is especially important for users who rely on keyboard navigation.
States
In error state, aria-invalid will be passed to indicate that the Input has an error, and providing support for an aria-errormessage to describe the error in more detail.
In disabled state, aria-hidden will be passed to make input not focusable.
In required state, aria-required will be passed to indicate that the Input is required.
Themed
The themed version of the component is a pre-styled version of the component, which allows you to quickly integrate the component into your project. The component's design and functionality are fully defined, allowing you to focus on the more important aspects of your project. To know more about Themed Library please visit this link.
Props
Input component is created using TextInput component from react-native. It extends all the props supported by React Native Text Input, utility props and the props mentioned below.
Input
Name
Value
Default
size
xl | lg | md | sm
md
variant
underlined | outline | rounded
outline
Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.
Examples
The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.
Input type password with FormControl
The Input component integrates with an icon and a button, providing users with a comprehensive login window inside a FormControl component.
{/* EyeIcon, EyeOffIcon are both imported from 'lucide-react-native' */}
<InputIcon
as={showPassword ?EyeIcon:EyeOffIcon}
color="$darkBlue500"
/>
</InputSlot>
</Input>
</VStack>
<Button
ml="auto"
onPress={()=>{
setShowModal(false)
}}
>
<ButtonTextcolor="$white">Save</ButtonText>
</Button>
</VStack>
</FormControl>
)
}
Input with Icons
The Input with Icons is a variation of the Input component that displays icons next to input field. It's commonly used in apps for a more visual representation of options and easier navigation.
<Input>
<InputSlotpl="$3">
<InputIconas={SearchIcon}/>
</InputSlot>
<InputFieldplaceholder="Search..."/>
</Input>
Unstyled
All the components in gluestack-ui are unstyled by default. To customize your UI using the extendedTheme, please refer to this link. The import names of components serve as keys to customize each component.
Spec Doc
Explore the comprehensive details of the Input in this document, including its implementation details, checklist, and potential future additions. Dive into the thought process behind the component and gain insights into its development journey.