Style Props
The style
prop group contains all properties related to visual styling, including colors, dimensions, and custom style objects for each part of the component.
Properties
Prop | Type | Default | Description |
---|---|---|---|
mainContainerStyle | ViewStyle | undefined | Style object for the outermost main container |
inputContainerStyle | ViewStyle | undefined | Style object for the input container |
inputContainerBackgroundColor | string | transparent | Color of the input container background |
inputStyle | TextStyle | ViewStyle | undefined | Style object for the input field |
labelTextStyle | TextStyle | undefined | Style object for the label text |
labelTextContainerStyle | ViewStyle | undefined | Style object for the label text container |
isRequired | boolean | false | Boolean to mark the input as required |
requiredTextStyle | TextStyle | undefined | Style object for the required text |
requiredTextColor | string | red | Color of the required text |
errorTextStyle | TextStyle | undefined | Style object for the error text |
Example
tsx
import { FormInput } from '@react-native-utils/forminput';
const StylePropsExample = () => (
<FormInput
text={{
labelText: "Username",
placeholderText: "Enter your username",
}}
style={{
isRequired: true,
mainContainerStyle: {
marginBottom: 16
},
inputContainerStyle: {
borderRadius: 8,
borderWidth: 1,
borderColor: '#CBD5E1',
},
inputContainerBackgroundColor: '#F8FAFC',
inputStyle: {
fontSize: 16,
},
labelTextStyle: {
fontSize: 16,
fontWeight: 'bold',
color: '#334155',
marginBottom: 8,
},
labelTextContainerStyle: {
marginBottom: 4
},
requiredTextStyle: {
fontWeight: 'bold',
},
requiredTextColor: '#F43F5E',
errorTextStyle: {
fontSize: 14,
fontStyle: 'italic',
}
}}
/>
);
Notes
- Style objects follow React Native's StyleSheet API
- Style props are broken down by component section for precise styling control
- For multiline inputs, set
multiline: true
in thecore
props group and providenumberOfLines
if needed - Error styling is automatically applied when the
error
prop (in thecore
group) is set to true