As many people are willing to learn React and master re usability by creating different components.
I have decided to create a list of how to create different components in Reactjs.
As react is extremely powerful and flexible in component re usability. We will take this to our advantage and will create different types of predefined components.
Creating custom components has many advantages.
Design Consistency
Native styles for different elements like (button, form elements, etc) differs from browser to browser. So by creating a custom component, we can ensure a consistent style.
Control
The behavior of the elements will be completely under our control and we can modify it according to our needs. Components can be a group of different elements like form elements that will always come with its label, that way we will not have to create it separately.
Data
We can return the data from each component according to our requirements. Like on hover return one type of data and on click return another type of data.
In my years of frontend development, one thing that I have learned is that if you are re-creating any component anywhere in the app, then it is better to make it generic because there is a high probability that you will have to use it again somewhere in the app.
We will be using React’s starter pack create-react-app
to create the component and I will be maintaining a GitHub repo where I will be storing the list.
To install react on your system make sure you have Nodejs and NPM installed. Once you have them on your system you can run
npm -g create-react-app
Which will install the create-react-app
globally. Now using this you can start a react project without doing any setup. It is really good at getting started with development.
To create a react project open the terminal, go to your desired drive or storage path and use this command.
create-react-app your-folder-name
You can use any name you want but just make sure that is smaller cased.
I had decided to use SASS but later dropped the idea because there are many people who may find it difficult to set up SASS. I will be using normal CSS for styling.
There are other few npm packages which I will be using in the development which may differ for some components. So I will mention them in the blog while writing.
The folder structure of our app is will be as follow
Inside the components
folder we will have our different components.
List of different react components
Form elements
- Create custom button component in react
- Create input component in react
- Create checkbox in react
- Create radio group component in react
- Create checkbox group component in react
- Create file uploader in react
- Create select dropdown in react
- Toggle switch in react
- Login form component in react
Generic components
- Create progress bar in react
- Pagination component in react
- Create accordion in react
- Create dropdown in react
- Create autocomplete search in react
- Sliding sidebar menu with hamburger in react
- Create tabs in react
- Create alert box in react
- Create modal component in react
- Create voice visualizer in react
- Lazy loading component in react.
- Create slider in react
- React drag and drop list of elements
- React image zoom
- Create timeline in react
- Create scroll indicator in react
- Create tooltip in react
- Typing effect component in react
- Create loader component in react
- How to scroll to top in react
- Image comparison slider in react
- Create scrollspy in react