react-native-textinput-effects
Text inputs with custom label and icon animations for iOS and android. Built with react native and inspired by Codrops.
Top Related Projects
Build forms in React, without the tears 😭
📋 React Hooks for form state management and validation (Web + React Native)
Performance-focused API for React forms 🚀
A Higher Order Component using react-redux to keep form state in a Redux store
Dead simple Object schema validation
🏁 Framework agnostic, high performance, subscription-based form state management
Quick Overview
react-native-textinput-effects is a React Native library that provides a collection of beautiful and customizable text input components. It offers various eye-catching effects and styles for text inputs, enhancing the user interface and user experience of React Native applications.
Pros
- Wide variety of pre-built text input effects
- Easy to implement and customize
- Smooth animations and transitions
- Compatible with both iOS and Android platforms
Cons
- May require additional styling for perfect integration with some app designs
- Limited documentation for advanced customization
- Some effects might be resource-intensive on older devices
- Occasional issues with text input behavior on certain Android versions
Code Examples
- Basic usage of the Hoshi text input effect:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
borderHeight={3}
inputPadding={16}
labelStyle={{ color: '#6a4162' }}
/>
- Using the Sae text input effect with custom colors:
import { Sae } from 'react-native-textinput-effects';
<Sae
label={'Email Address'}
iconClass={FontAwesomeIcon}
iconName={'pencil'}
iconColor={'#f4d29a'}
inputPadding={16}
labelStyle={{ color: '#f4d29a' }}
borderHeight={3}
autoCapitalize={'none'}
autoCorrect={false}
/>
- Implementing the Kohana text input effect with a custom icon:
import { Kohana } from 'react-native-textinput-effects';
import Icon from 'react-native-vector-icons/FontAwesome';
<Kohana
style={{ backgroundColor: '#f9f5ed' }}
label={'Phone Number'}
iconClass={Icon}
iconName={'phone'}
iconColor={'#f4d29a'}
labelStyle={{ color: '#91627b' }}
inputStyle={{ color: '#91627b' }}
/>
Getting Started
-
Install the package:
npm install react-native-textinput-effects
-
Import the desired text input effect in your component:
import { Hoshi } from 'react-native-textinput-effects';
-
Use the component in your render method:
<Hoshi label={'Username'} borderColor={'#b76c94'} borderHeight={3} inputPadding={16} />
-
Customize the component props as needed for your specific use case.
Competitor Comparisons
Build forms in React, without the tears 😭
Pros of Formik
- More comprehensive form management solution, handling state, validation, and submission
- Highly flexible and customizable, works with any UI library
- Large community and ecosystem with extensive documentation
Cons of Formik
- Steeper learning curve due to its more complex API
- Requires additional setup and configuration compared to simpler input libraries
- May be overkill for basic form needs or single input fields
Code Comparison
Formik:
<Formik
initialValues={{ email: '' }}
onSubmit={values => console.log(values)}
>
{({ handleChange, handleSubmit, values }) => (
<TextInput
onChangeText={handleChange('email')}
value={values.email}
/>
)}
</Formik>
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Email'}
borderColor={'#b76c94'}
onChangeText={(text) => console.log(text)}
/>
While Formik provides a complete form management solution, react-native-textinput-effects focuses on creating visually appealing input fields with minimal setup. Formik is better suited for complex forms with multiple fields and validations, while react-native-textinput-effects excels in quickly implementing stylish individual input components.
📋 React Hooks for form state management and validation (Web + React Native)
Pros of react-hook-form
- More versatile, can be used for various form types beyond text inputs
- Offers advanced form validation and error handling capabilities
- Provides better performance with minimal re-renders
Cons of react-hook-form
- Steeper learning curve for beginners
- Requires more setup and configuration for basic use cases
- Not specifically designed for React Native, may need additional adaptations
Code Comparison
react-hook-form:
import { useForm } from 'react-hook-form';
const { register, handleSubmit } = useForm();
const onSubmit = data => console.log(data);
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register("example")} />
<input type="submit" />
</form>
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
inputPadding={16}
onChangeText={(text) => console.log(text)}
/>
react-hook-form is a comprehensive form management library for React applications, offering powerful validation and state management features. It's highly flexible but may require more setup for simple use cases.
react-native-textinput-effects focuses on providing visually appealing text input components for React Native, with pre-designed effects and styles. It's easier to use for basic text inputs but lacks advanced form management features.
Choose react-hook-form for complex form handling and validation needs, and react-native-textinput-effects for quick, stylish text inputs in React Native apps.
Performance-focused API for React forms 🚀
Pros of unform
- More comprehensive form management solution, handling state, validation, and submission
- Supports multiple UI libraries and frameworks beyond React Native
- Offers a plugin system for extending functionality
Cons of unform
- Steeper learning curve due to its more complex API
- May be overkill for simple form implementations
- Less focused on input styling and effects compared to react-native-textinput-effects
Code Comparison
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
borderHeight={3}
inputPadding={16}
labelStyle={{ color: '#ac83c4' }}
/>
unform:
import { Form } from '@unform/core';
import { Input } from '@unform/mobile';
<Form onSubmit={handleSubmit}>
<Input name="username" label="Username" />
<Button onPress={() => formRef.current.submitForm()}>Submit</Button>
</Form>
The code comparison shows that react-native-textinput-effects focuses on styling and effects for individual inputs, while unform provides a more structured approach to form management with less emphasis on input appearance.
A Higher Order Component using react-redux to keep form state in a Redux store
Pros of redux-form
- Integrates seamlessly with Redux, providing a centralized state management for forms
- Offers advanced features like field-level validation, dynamic form generation, and form submission handling
- Supports a wide range of input types and custom form elements
Cons of redux-form
- Steeper learning curve, especially for developers new to Redux
- Can be overkill for simple forms or applications not using Redux
- Requires more boilerplate code compared to simpler form solutions
Code Comparison
redux-form:
import { reduxForm, Field } from 'redux-form';
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'myForm' })(MyForm);
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
const MyInput = () => (
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
inputPadding={16}
/>
);
While redux-form focuses on form state management and integration with Redux, react-native-textinput-effects provides visually appealing input components for React Native. The choice between them depends on the project's requirements, with redux-form being more suitable for complex form handling in Redux-based applications, and react-native-textinput-effects offering easy-to-use, stylish input components for React Native projects.
Dead simple Object schema validation
Pros of yup
- More versatile, can be used for general object schema validation
- Supports complex validation rules and custom error messages
- Integrates well with form libraries like Formik
Cons of yup
- Not specifically designed for React Native input styling
- Requires more setup and configuration for basic input validation
- Steeper learning curve for beginners
Code Comparison
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
borderHeight={3}
inputPadding={16}
/>
yup:
import * as Yup from 'yup';
const schema = Yup.object().shape({
username: Yup.string().required('Username is required'),
email: Yup.string().email('Invalid email').required('Email is required'),
});
Summary
react-native-textinput-effects focuses on providing visually appealing input components for React Native, with various pre-designed styles. yup, on the other hand, is a powerful schema validation library that can be used across different JavaScript environments. While react-native-textinput-effects offers ready-to-use styled inputs, yup provides flexible and extensive validation capabilities that can be integrated with various form solutions.
🏁 Framework agnostic, high performance, subscription-based form state management
Pros of final-form
- More comprehensive form management solution
- Framework-agnostic, can be used with various UI libraries
- Supports advanced features like form validation and submission handling
Cons of final-form
- Steeper learning curve due to its more complex API
- Requires additional setup and configuration
- May be overkill for simple form implementations
Code Comparison
react-native-textinput-effects:
import { Hoshi } from 'react-native-textinput-effects';
<Hoshi
label={'Username'}
borderColor={'#b76c94'}
borderHeight={3}
inputPadding={16}
/>
final-form:
import { Form, Field } from 'react-final-form';
<Form
onSubmit={onSubmit}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" placeholder="Username" />
<button type="submit">Submit</button>
</form>
)}
/>
Summary
react-native-textinput-effects is a specialized library for creating visually appealing text input components in React Native, while final-form is a more comprehensive form management solution for various JavaScript frameworks. react-native-textinput-effects is easier to use for simple, stylized inputs, but final-form offers more advanced features and flexibility for complex form handling across different platforms.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
React Native Textinput Effects
I've come across with those beautiful text inputs created and blogged by Codrops 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.
There is also a native iOS library called TextFieldEffects which has built some of them in Swift.
Blog Post
I've recently written a blog post about Creating an Animated TextField with React Native. While it isn't directly related to this library, I think you might still find it useful to understand the basics of creating an animated text input with React Native Animated
library.
Installation
The latest version of this project needs react-native >= 0.55(March 2018 release) due to createRef usage. Go with the latest version:
$ npm install react-native-textinput-effects --save
You can stick with version 0.4 if you have an older react-native version:
$ npm install react-native-textinput-effects@0.4.2 --save
You also need to install react-native-vector-icons if you'd like to use a TextInputEffect component with an icon. Please check out Installation section on that project.
How to use
Common Props
Prop | Type | Description |
---|---|---|
label | String | Displayed as placeholder string of the input. |
style | View Style Object | Applied to the root container of the input. |
labelStyle | View Style Object | Applied to the container of the label view. |
inputStyle | Text Style Object | Applied to the TextInput component. |
value | String | This value will be applied to the TextInput and change it's state on every render. Use this prop if you want a Controlled Component. |
defaultValue | String | If you want to initialize the component with a non-empty value, you can supply a defaultValue prop. This prop creates an Uncontrolled Component and is only used during initial render. |
You can also use default TextInput Props. They'll be passed into TextInput component. E.g., use TextInput
's onChange
prop to be notified on text changes.
<Sae
onChangeText={(text) => { this.setState({textValue: text}) }
/>
Props for TextInputEffects with an Icon
This component needs Icon
component from react-native-vector-icons
to operate with icons. You should import it before creating a TextInputEffects component.
import Icon from 'react-native-vector-icons/FontAwesome';
Prop | Type | Description |
---|---|---|
iconClass | Object | The Icon component class you've imported from react-native-vector-icons. |
iconName | String | Name of the icon that is passed to Icon component. |
iconColor | String | Applied to the Icon component. |
iconSize | Number | Applied to the Icon component. |
Example
See TextInputEffectsExample.js file.
Follow those steps to run the example:
- Clone the repo
git clone https://github.com/halilb/react-native-textinput-effects && cd react-native-textinput-effects/Example
- Install dependencies `npm install``
- Follow official instructions to run the example project in a simulator or device.
You can also check out the example library without any installation on Appetize.io!
Input Types
Sae
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import { Sae } from 'react-native-textinput-effects';
const saeInput = (
<Sae
label={'Email Address'}
iconClass={FontAwesomeIcon}
iconName={'pencil'}
iconColor={'white'}
inputPadding={16}
labelHeight={24}
// active border height
borderHeight={2}
// TextInput props
autoCapitalize={'none'}
autoCorrect={false}
/>
);
Fumi
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import { Fumi } from 'react-native-textinput-effects';
const fumiInput = (
<Fumi
label={'Course Name'}
iconClass={FontAwesomeIcon}
iconName={'university'}
iconColor={'#f95a25'}
iconSize={20}
iconWidth={40}
inputPadding={16}
/>
);
Kohana
Kohana supports Animated Native Driver. You can use native driver by passing useNativeDriver
.
import MaterialsIcon from 'react-native-vector-icons/MaterialIcons';
import { Kohana } from 'react-native-textinput-effects';
const kohanaInput = (
<Kohana
style={{ backgroundColor: '#f9f5ed' }}
label={'Line'}
iconClass={MaterialsIcon}
iconName={'directions-bus'}
iconColor={'#f4d29a'}
inputPadding={16}
labelStyle={{ color: '#91627b' }}
inputStyle={{ color: '#91627b' }}
labelContainerStyle={{ padding: 20 }}
iconContainerStyle={{Â padding: 20 }}
useNativeDriver
/>
);
Makiko
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import { Makiko } from 'react-native-textinput-effects';
const makikoInput = (
<Makiko
label={'Comment'}
iconClass={FontAwesomeIcon}
iconName={'comment'}
iconColor={'white'}
inputPadding={16}
inputStyle={{ color: '#db786d' }}
/>
);
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.
Isao
import { Isao } from 'react-native-textinput-effects';
const isaoInput = (
<Isao
label={'First Name'}
// this is applied as active border and label color
activeColor={'#da7071'}
// active border height
borderHeight={8}
inputPadding={16}
labelHeight={24}
// this is applied as passive border and label color
passiveColor={'#dadada'}
/>
);
Hoshi
import { Hoshi } from 'react-native-textinput-effects';
const hoshiInput = (
<Hoshi
label={'Town'}
// this is used as active border color
borderColor={'#b76c94'}
// active border height
borderHeight={3}
inputPadding={16}
// this is used to set backgroundColor of label mask.
// please pass the backgroundColor of your TextInput container.
backgroundColor={'#F9F7F6'}
/>
);
Jiro
import { Jiro } from 'react-native-textinput-effects';
const jiroInput = (
<Jiro
label={'Dog\'s name'}
// this is used as active and passive border color
borderColor={'#9b537a'}
inputPadding={16}
inputStyle={{ color: 'white' }}
/>
);
Kaede
import { Kaede } from 'react-native-textinput-effects';
const kaedeInput = (
<Kaede
label={'Website'}
inputPadding={16}
/>
);
Akira
import { Akira } from 'react-native-textinput-effects';
const akiraInput = (
<Akira
label={'First Name'}
// this is used as active and passive border color
borderColor={'#a5d1cc'}
inputPadding={16}
labelHeight={24}
labelStyle={{ color: '#ac83c4' }}
/>
);
Madoka
import { Madoka } from 'react-native-textinput-effects';
const madokaInput = (
<Madoka
label={'Frequency'}
// this is used as active and passive border color
borderColor={'#aee2c9'}
inputPadding={16}
labelHeight={24}
labelStyle={{ color: '#008445' }}
inputStyle={{ color: '#f4a197' }}
/>
);
Hideo
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import { Hideo } from 'react-native-textinput-effects';
const hideoInput = (
<Hideo
iconClass={FontAwesomeIcon}
iconName={'envelope'}
iconColor={'white'}
// this is used as backgroundColor of icon container view.
iconBackgroundColor={'#f2a59d'}
inputStyle={{ color: '#464949' }}
/>
);
Licence
Top Related Projects
Build forms in React, without the tears 😭
📋 React Hooks for form state management and validation (Web + React Native)
Performance-focused API for React forms 🚀
A Higher Order Component using react-redux to keep form state in a Redux store
Dead simple Object schema validation
🏁 Framework agnostic, high performance, subscription-based form state management
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot