xfor-text-field
XForTextField React Component

Demo app with implemented component
Install
npm install --save xfor-text-field
Peer dependencies:
- react: ^16.8.6"
- react-dom: ^16.8.6"
- styled-components: ^4.3.2
Usage
XFor TextField component is designed for projects using styled-components.
Styles of this component expect box-sizing: border-box; set globally for all nodes and base font size set to 10px:
html {
font-size: 10px;
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
body {
font-size: 100%;
}
You can style this component by specifing some props in your theme (props shown here are the default ones):
const theme = {
xfor: {
textField: {
height: 40,
fontColor: '#000000',
borderColor: '#d8d8d8',
borderErroredColor: 'red',
bgColor: '#FFFFFF',
bgDisabledColor: '#ececec',
bgErroredColor: '#ffd9d9',
fontDisabledColor: '#9a9a9a',
labelColor: '#9c9c9c',
},
},
};
XFor TextField component dumb as much as possible, though, you need to wrap it in a class to manage its state. Check the example app here.
List of props you can pass to the component:
type TextFieldProps = {
value: string;
isFocused: boolean;
errorMessage: string;
isTouched: boolean;
label: string;
name: string;
type: TextFieldType;
disabled: boolean;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
onFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
onBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
};
License
MIT © Michał Wrzosek
michal@wrzosek.pl
https://michal.wrzosek.pl
This package was bootstrapped with react-component-lib