|
| 1 | +# React Native Textinput Effects |
| 2 | + |
| 3 | +I've come across with [those beautiful](http://tympanus.net/Development/TextInputEffects) text inputs created and [blogged](http://tympanus.net/codrops/2015/01/08/inspiration-text-input-effects) by **Coderops** and wanted to port them to react-native. Some of those text fields are now ready to use in iOS and android thanks to react-native. |
| 4 | + |
| 5 | +There is also a native iOS library called [TextFieldEffects](https://github.com/raulriera/TextFieldEffects) which has built some of them in Swift. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## Installation |
| 10 | +`$ npm install react-native-textinput-effects --save` |
| 11 | + |
| 12 | +You also need to install [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons) if you'd like to use a TextInputEffect component with an icon. Please check out [Installation section](https://github.com/oblador/react-native-vector-icons#installation) on that project. |
| 13 | + |
| 14 | +## How to use |
| 15 | + |
| 16 | +### Common Props |
| 17 | + |
| 18 | +| Prop | Type | Description | |
| 19 | +|---|---|---| |
| 20 | +|**`label`**|String|Displayed as placeholder string of the input.| |
| 21 | +|**`style`**|View Style Object|Applied to the root container of the input.| |
| 22 | +|**`labelStyle`**|View Style Object|Applied to the container of the label view.| |
| 23 | +|**`inputStyle`**|Text Style Object|Applied to the TextInput component.| |
| 24 | + |
| 25 | +You can also use [TextInput Props](https://facebook.github.io/react-native/docs/textinput.html#props). They'll be passed into TextInput component. |
| 26 | + |
| 27 | +### Props for TextInputEffects with an Icon |
| 28 | + |
| 29 | +This component needs `Icon` component from `react-native-vector-icons` to operate with icons. You should import it before creating a TextInputEffects component. |
| 30 | + |
| 31 | +`import Icon from 'react-native-vector-icons/FontAwesome';` |
| 32 | + |
| 33 | +| Prop | Type | Description | |
| 34 | +|---|---|---| |
| 35 | +|**`iconClass`**|Object|The Icon component class you've imported from react-native-vector-icons.| |
| 36 | +|**`iconName`**|String|Name of the icon that is passed to Icon component.| |
| 37 | +|**`iconColor`**|String|Applied to the container of the label view.| |
| 38 | +|**`inputStyle`**|Text Style Object|Applied to the TextInput component.| |
| 39 | + |
| 40 | + |
| 41 | +## Example |
| 42 | + |
| 43 | +See [TextInputEffectsExample.js](Example/TextInputEffectsExample.js) file. |
| 44 | + |
| 45 | +Follow those steps to run the example: |
| 46 | + |
| 47 | +1. Clone the repo `git clone https://github.com/halilb/react-native-textinput-effects && cd react-native-textinput-effects/Example` |
| 48 | +2. Install dependencies `npm install`` |
| 49 | +3. Follow [official instructions](https://facebook.github.io/react-native/docs/getting-started.html) to run the example project in a simulator or device. |
| 50 | + |
| 51 | +## Input Types |
| 52 | + |
| 53 | +### Sae |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +```js |
| 59 | +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; |
| 60 | +import { Sae } from 'react-native-textinput-effects'; |
| 61 | + |
| 62 | +const saeInput = ( |
| 63 | + <Sae |
| 64 | + label={'Email Address'} |
| 65 | + iconClass={FontAwesomeIcon} |
| 66 | + iconName={'pencil'} |
| 67 | + iconColor={'white'} |
| 68 | + // TextInput props |
| 69 | + autoCapitalize={'none'} |
| 70 | + autoCorrect={false} |
| 71 | + /> |
| 72 | +); |
| 73 | +``` |
| 74 | + |
| 75 | +### Fumi |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +```js |
| 81 | +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; |
| 82 | +import { Fumi } from 'react-native-textinput-effects'; |
| 83 | + |
| 84 | +const fumiInput = ( |
| 85 | + <Fumi |
| 86 | + label={'Course Name'} |
| 87 | + iconClass={FontAwesomeIcon} |
| 88 | + iconName={'university'} |
| 89 | + iconColor={'#f95a25'} |
| 90 | + /> |
| 91 | +); |
| 92 | +``` |
| 93 | +### Kohana |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +```js |
| 99 | +import MaterialsIcon from 'react-native-vector-icons/MaterialIcons'; |
| 100 | +import { Kohana } from 'react-native-textinput-effects'; |
| 101 | + |
| 102 | +const kohanaInput = ( |
| 103 | + <Kohana |
| 104 | + style={{ backgroundColor: '#f9f5ed' }} |
| 105 | + label={'Line'} |
| 106 | + iconClass={MaterialsIcon} |
| 107 | + iconName={'directions-bus'} |
| 108 | + iconColor={'#f4d29a'} |
| 109 | + labelStyle={{ color: '#91627b' }} |
| 110 | + inputStyle={{ color: '#91627b' }} |
| 111 | + /> |
| 112 | +); |
| 113 | +``` |
| 114 | + |
| 115 | +### Makiko |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +```js |
| 121 | +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; |
| 122 | +import { Makiko } from 'react-native-textinput-effects'; |
| 123 | + |
| 124 | +const makikoInput = ( |
| 125 | + <Makiko |
| 126 | + label={'Comment'} |
| 127 | + iconClass={FontAwesomeIcon} |
| 128 | + iconName={'comment'} |
| 129 | + iconColor={'white'} |
| 130 | + inputStyle={{ color: '#db786d' }} |
| 131 | + /> |
| 132 | +); |
| 133 | +``` |
| 134 | +Note: Icon component expands and covers the input. So, the icon should not have any blank spaces for the animation experience. This is the limitation for Makiko. |
| 135 | + |
| 136 | +### Isao |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | +```js |
| 142 | +import { Isao } from 'react-native-textinput-effects'; |
| 143 | + |
| 144 | +const isaoInput = ( |
| 145 | + <Isao |
| 146 | + label={'First Name'} |
| 147 | + // this is applied as active border and label color |
| 148 | + activeColor={'#da7071'} |
| 149 | + // this is applied as passive border and label color |
| 150 | + passiveColor={'#dadada'} |
| 151 | + /> |
| 152 | +); |
| 153 | +``` |
| 154 | + |
| 155 | +### Hoshi |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | +```js |
| 161 | +import { Hoshi } from 'react-native-textinput-effects'; |
| 162 | + |
| 163 | +const hoshiInput = ( |
| 164 | + <Hoshi |
| 165 | + label={'Town'} |
| 166 | + // this is used as active border color |
| 167 | + borderColor={'#b76c94'} |
| 168 | + // this is used to set backgroundColor of label mask. |
| 169 | + // please pass the backgroundColor of your TextInput container. |
| 170 | + backgroundColor={'#F9F7F6'} |
| 171 | + /> |
| 172 | +); |
| 173 | +``` |
| 174 | + |
| 175 | +### Jiro |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | +```js |
| 181 | +import { Jiro } from 'react-native-textinput-effects'; |
| 182 | + |
| 183 | +const jiroInput = ( |
| 184 | + <Jiro |
| 185 | + label={'Dog\'s name'} |
| 186 | + // this is used as active and passive border color |
| 187 | + borderColor={'#9b537a'} |
| 188 | + inputStyle={{ color: 'white' }} |
| 189 | + /> |
| 190 | +); |
| 191 | +``` |
| 192 | + |
| 193 | +### Kaede |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | +```js |
| 199 | +import { Kaede } from 'react-native-textinput-effects'; |
| 200 | + |
| 201 | +const kaedeInput = ( |
| 202 | + <Kaede |
| 203 | + label={'Website'} |
| 204 | + /> |
| 205 | +); |
| 206 | +``` |
| 207 | + |
| 208 | +### Akira |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | +```js |
| 214 | +import { Akira } from 'react-native-textinput-effects'; |
| 215 | + |
| 216 | +const akiraInput = ( |
| 217 | + <Akira |
| 218 | + label={'First Name'} |
| 219 | + // this is used as active and passive border color |
| 220 | + borderColor={'#a5d1cc'} |
| 221 | + labelStyle={{ color: '#ac83c4' }} |
| 222 | + /> |
| 223 | +); |
| 224 | +``` |
| 225 | + |
| 226 | +### Madoka |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | +```js |
| 232 | +import { Madoka } from 'react-native-textinput-effects'; |
| 233 | + |
| 234 | +const madokaInput = ( |
| 235 | + <Madoka |
| 236 | + label={'Frequency'} |
| 237 | + // this is used as active and passive border color |
| 238 | + borderColor={'#aee2c9'} |
| 239 | + labelStyle={{ color: '#008445' }} |
| 240 | + inputStyle={{ color: '#f4a197' }} |
| 241 | + /> |
| 242 | +); |
| 243 | +``` |
| 244 | + |
| 245 | +### Hideo |
| 246 | + |
| 247 | + |
| 248 | + |
| 249 | + |
| 250 | +```js |
| 251 | +import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; |
| 252 | +import { Hideo } from 'react-native-textinput-effects'; |
| 253 | + |
| 254 | +const hideoInput = ( |
| 255 | + <Hideo |
| 256 | + iconClass={FontAwesomeIcon} |
| 257 | + iconName={'envelope'} |
| 258 | + iconColor={'white'} |
| 259 | + // this is used as backgroundColor of icon container view. |
| 260 | + iconBackgroundColor={'#f2a59d'} |
| 261 | + inputStyle={{ color: '#464949' }} |
| 262 | + /> |
| 263 | +); |
| 264 | +``` |
| 265 | + |
| 266 | +## Licence |
| 267 | +[MIT](http://opensource.org/licenses/mit-license.html) |
0 commit comments