Styled CheckBox in React

vigu
3 min readApr 19, 2019

--

Hi! One of the most important factors in developing the websites is to maintain the uniformity/ standard styles throughout the site.

If you want to maintain the uniformity, then the input elements might pop out in your mind. Because we can’t use the in-built styles of the elements.

The input elements’ style differs based on the OS and browsers whereas the functionality remains the same

So, it is better to create our own customized Checkbox with cross-browser & OS compatibility.

Also, we should mind about providing all the major functionality with limited CSS and javascript coding. It should be reusable which I consider the most important factor for a developer.

Unchecked state
Checked state

Here, I’ve attached the working model with the code in codepen.io

In this checkbox components, you can maintain the uniformity throughout your website. Now we’ve created our checkbox which can simply check and uncheck the item. With this, we cannot achieve a better user experience.

Error state

Yeah, we have to think about the focused state of the checkbox when you didn’t check the checkbox and clicks a button. By default, the focused label will be scrolled into view. The same functionality we can apply in this component too and I’ve written in the code. Even if you have any other ideas, comment it down.

PS:

You can also check my blog about scrollIntoView() to support all the browsers.

I am in the mission of writing content for the budding developers. I am more likable to write about a simple solution for a problem that seems to be tough at first sight but actually, it’s not. If you have such any ideas or faced at your career inception, drop in the comment box.

Please write if you have any queries, ideas or anything to write about in the future.

Here we go with the crazy sign off (please read as you can watch in the youtube channels) Please, Like, Comment, Follow & Subscribe to my blog site!!!

Mind reading about my other blogs? How about reading React Dropdown?!

--

--

vigu
vigu

Written by vigu

Goal: I’m making a friendship with HTML, CSS & JS | Mission: Trying to write what’s under the hood of UI tech

No responses yet