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 — FormControl | NativeBase | Universal Components for React and React Native

FormControl | 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.
FormControl
FormControl is used to form elements by providing context such as isInvalid, isDisabled, and isRequired.
Show Code
Playground
const Example = () => {
return <Box w="100%">
<FormControl isRequired>
<Stack mx="4">
<FormControl.Label>Password</FormControl.Label>
<Input _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"
}
}} shadow={2} type="password" defaultValue="12345" placeholder="password" />
<FormControl.HelperText>
Must be atleast 6 characters.
</FormControl.HelperText>
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
Atleast 6 characters are required.
</FormControl.ErrorMessage>
</Stack>
</FormControl>
</Box>;
};
Examples
Basic
Playground
const Example = () => {
return <Box alignItems="center">
<Box w="100%" maxWidth="300px">
<FormControl isRequired>
<Stack mx="4">
<FormControl.Label>Password</FormControl.Label>
<Input type="password" defaultValue="12345" placeholder="password" />
<FormControl.HelperText>
Must be atleast 6 characters.
</FormControl.HelperText>
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
Atleast 6 characters are required.
</FormControl.ErrorMessage>
</Stack>
</FormControl>
</Box>
</Box>;
};
Custom Style
Playground
const Example = () => {
return <ScrollView w="100%">
<Stack space={2.5} alignSelf="center" px="4" safeArea mt="4" w={{
base: "100%",
md: "25%"
}}>
<Box>
<Text bold fontSize="xl" mb="4">
Default
</Text>
<FormControl mb="5">
<FormControl.Label>Project Title</FormControl.Label>
<Input />
<FormControl.HelperText>
Give your project a title.
</FormControl.HelperText>
</FormControl>
<Divider />
</Box>
<Box>
<Text bold fontSize="xl" mb="4">
Disabled
</Text>
<FormControl isDisabled mb="5">
<FormControl.Label _disabled={{
_text: {
color: "gray.400",
fontWeight: "bold"
}
}}>
Project Title
</FormControl.Label>
<Input placeholder="Title" />
<FormControl.HelperText>
Give your project a title.
</FormControl.HelperText>
</FormControl>
<Divider />
</Box>
<Box>
<Text bold fontSize="xl" mb="4">
Invalid
</Text>
<FormControl isInvalid>
<FormControl.Label>Project Title</FormControl.Label>
<Input placeholder="Title" />
<FormControl.ErrorMessage leftIcon={<WarningOutlineIcon size="xs" />}>
Something is wrong.
</FormControl.ErrorMessage>
</FormControl>
</Box>
</Stack>
</ScrollView>;
};
Props
FormControl
FormControl implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
LayoutProps
,
ColorProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
nativeID
If provided, this prop is passed to its children.
Type: string
isInvalid
If true, this prop is passed to its children.
Type: boolean
isRequired
If true, this prop is passed to its children.
Type: boolean
isDisabled
If true, this prop is passed to its children.
Type: boolean
isReadOnly
If true, this prop is passed to its children.
Type: boolean
FormControl.Label
FormControlLabel implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
LayoutProps
,
ColorProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
_disabled
Passed props will be applied on disabled state.
Type: Partial<IBoxProps<IFormControlLabelProps>>
_invalid
Passed props will be applied on invalid state.
Type: Partial<IBoxProps<IFormControlLabelProps>>
htmlFor
Reflects the value of the 'for' content property.
Type: string
_astrick
Props applied to astrick text
Type: Partial<ITextProps>
FormControl.ErrorMessage
FormControlErrorMessage implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
LayoutProps
,
ColorProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
_disabled
Passed props will be applied on disabled state.
Type: Partial<IBoxProps<IFormControlLabelProps>>
rightIcon
The right icon element to use in the FormControl.ErrorMessage.
Type: Element | Element[]
leftIcon
The left icon element to use in the FormControl.ErrorMessage.
Type: Element | Element[]
startIcon
The start icon element to use in the FormControl.ErrorMessage.
Type: Element | Element[]
endIcon
The end icon element to use in the FormControl.ErrorMessage.
Type: Element | Element[]
_stack
Props to be passed to the HStack used inside of FormControl.ErrorMessage.
Type: Partial<IStackProps>
FormControl.HelperText
FormControlHelperText implements
View
,
SafeAreaProps
,
PlatformProps
,
FlexProps
,
LayoutProps
,
ColorProps
,
BorderProps
,
TypographyProps
,
ShadowProps
,
PositionProps
_disabled
Passed props will be applied on disabled state.
Type: Partial<IBoxProps<IFormControlLabelProps>>
_invalid
Passed props will be applied on invalid state.
Type: Partial<IBoxProps<IFormControlLabelProps>>
Styling
NativeBase ships with a default theme for each component. Check out the default theme of the formControl
here
.
Info: We can easily extend the formControl component theme using extendTheme function as described in the documentation
here
.
Previous
Checkbox
Next
IconButton
Quick Nav
Examples
Basic
Custom Style
Props
FormControl
FormControl.Label
FormControl.ErrorMessage
FormControl.HelperText
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.