GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — Input | NativeBase | Universal Components for React and React Native

Input | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
If you are starting a new project, please try gluestack-ui for better performance and new design.
Input
The Input component allows a user to provide input in a text field.
Show Code
Playground
const Example = () => {
return <Input shadow={2} _light={{
bg: "coolGray.100",
_hover: {
bg: "coolGray.200"
},
_focus: {
bg: "coolGray.200:alpha.70"
}
}} _dark={{
bg: "coolGray.800",
_hover: {
bg: "coolGray.900"
},
_focus: {
bg: "coolGray.900:alpha.70"
}
}} placeholder="Enter your name" />;
};
Examples
Basic
Playground
const Example = () => {
return <Box alignItems="center">
<Input mx="3" placeholder="Input" w="100%" />
</Box>;
};
Input Sizes
Playground
const Example = () => {
return <Stack space={4} w="75%" maxW="300px" mx="auto">
<Input size="xs" placeholder="xs Input" />
<Input size="sm" placeholder="sm Input" />
<Input size="md" placeholder="md Input" />
<Input size="lg" placeholder="lg Input" />
<Input size="xl" placeholder="xl Input" />
<Input size="2xl" placeholder="2xl Input" />
</Stack>;
};
Input Variants
Playground
const Example = () => {
return <Stack space={4} w="75%" maxW="300px" mx="auto">
<Input variant="outline" placeholder="Outline" />
<Input variant="filled" placeholder="Filled" />
<Input variant="underlined" placeholder="Underlined" />
<Input variant="unstyled" placeholder="Unstyled" />
<Input variant="rounded" placeholder="Round" />
</Stack>;
};
Input Addons
Playground
const Example = () => {
return <Stack alignItems="center">
<InputGroup w={{
base: "70%",
md: "285"
}}>
<InputLeftAddon children={"https://"} />
<Input w={{
base: "70%",
md: "100%"
}} placeholder="nativebase" />
<InputRightAddon children={".io"} />
</InputGroup>
</Stack>;
};
Input Elements
Playground
const Example = () => {
const [show, setShow] = React.useState(false);
return <Stack space={4} w="100%" alignItems="center">
<Input w={{
base: "75%",
md: "25%"
}} InputLeftElement={<Icon as={<MaterialIcons name="person" />} size={5} ml="2" color="muted.400" />} placeholder="Name" />
<Input w={{
base: "75%",
md: "25%"
}} type={show ? "text" : "password"} InputRightElement={<Pressable onPress={() => setShow(!show)}>
<Icon as={<MaterialIcons name={show ? "visibility" : "visibility-off"} />} size={5} mr="2" color="muted.400" />
</Pressable>} placeholder="Password" />
</Stack>;
};
Password Input
Playground
const Example = () => {
const [show, setShow] = React.useState(false);
const handleClick = () => setShow(!show);
return <Box alignItems="center">
<Input type={show ? "text" : "password"} w="100%" py="0" InputRightElement={<Button size="xs" rounded="none" w="1/6" h="full" onPress={handleClick}>
{show ? "Hide" : "Show"}
</Button>} placeholder="Password" />
</Box>;
};
Controlled Input
Playground
const Example = () => {
const [value, setValue] = React.useState("");
const handleChange = text => setValue(text);
return <Box alignItems="center">
<Input value={value} w="100%" onChangeText={handleChange} placeholder="Value Controlled Input" />
</Box>;
};
Form Controlled
Playground
const Example = () => {
return <Box alignItems="center">
<FormControl isInvalid w="75%" maxW="300px">
<FormControl.Label>Password</FormControl.Label>
<Input placeholder="Enter password" />
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
Try different from previous passwords.
</FormControl.ErrorMessage>
</FormControl>
</Box>;
};
Props
Input
Input implements
FlexProps
,
View
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
BackgroundProps
,
PlatformProps
size
The size of the input.
Type: ThemeComponentSizeType<"Input">
Default: 'md'
variant
The variant of the input style to use.
Type: ResponsiveValue<"outline" | "underlined" | "rounded" | "filled" | "unstyled" | (string & {})>
Default: 'outline'
isHovered
If true, the input will be hovered.
Type: boolean
isFocused
If true, the input will be focused.
Type: boolean
InputLeftElement
If given, adds the provided element to the left of the input.
Type: Element | Element[]
InputRightElement
If given, adds the provided element to the right of the input.
Type: Element | Element[]
leftElement
If given, adds the provided element to the left of the input.
Type: Element | Element[]
rightElement
If given, adds the provided element to the right of the input.
Type: Element | Element[]
isInvalid
If true, the input will indicate an error.
Type: boolean
isDisabled
If true, the input will be disabled.
Type: boolean
isRequired
This will set aria-required="true" on web when passed in formcontrol.
Type: boolean
isReadOnly
If true, prevents the value of the input from being edited.
Type: boolean
isFullWidth
If true, the input element will span the full width of its parent
Type: boolean
type
Using the type password, user can mask the input.
Type: "text" | "password"
wrapperRef
Ref to be passed to Icon's wrapper Box
Type: any
_hover
Passed props will be applied on hovered state.
Type: Partial<IInputProps>
_focus
Passed props will be applied on focused state.
Type: Partial<IInputProps>
_disabled
Passed props will be applied on disabled state.
Type: Partial<IInputProps>
_readOnly
Passed props will be applied on readOnly state.
Type: Partial<IInputProps>
_invalid
Passed props will be applied on invalid state.
Type: Partial<IInputProps>
_input
props are passed to InputBase component
Type: Partial<IInputProps>
_stack
Props to be passed to the Stack used inside.
Type: Partial<IStackProps>
focusOutlineColor
This prop allows you to change outlineColor when input is in the focused state
Type: ColorType
invalidOutlineColor
This prop allows you to change outlineColor when input is in invalid state
Type: ColorType
Input.Group
InputGroup implements
View
,
SafeAreaProps
,
PlatformProps
,
ColorProps
,
LayoutProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
,
FlexProps
variant
The variant of the input style to use.
Type: string
Default: 'outline'
size
The size of the input.
Type: ResponsiveValue<number | "px" | "full" | "sm" | "6" | "2xs" | "2" | "8" | "xs" | "3" | "12" | "md" | "4" | "16" | "xl" | "5" | "24" | "32" | "7" | "0.5" | "2.5" | "lg" | "1" | "2xl" | "1.5" | "10" | "20" | ... 27 more ... | (string & {})>
Default: 'md'
Styling
NativeBase ships with a default theme for each component. Check out the default theme of the input
here
.
Info: We can easily extend the input component theme using extendTheme function as described in the documentation
here
.
Previous
IconButton
Next
Link
Quick Nav
Examples
Basic
Input Sizes
Input Variants
Input Addons
Input Elements
Password Input
Controlled Input
Form Controlled
Props
Input
Input.Group
Styling
MadeWithNativeBase
gluestack-ui
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.