Custom Checkboxes Using CSS and Font Awesome
Posted By : Gaurav Arora | 27-Jun-2017
Hi Guys, In this blog we are going to create custom checkboxes using css and font awesome icons.
As we all know that in every single app, we can see the use of these custom checkboxes, as they looks nice comparing with the default ones. How can we do that?
We can simply create these custom checkboxes with the help of CSS and we will also use font awesome css for the icons that we will require for the checked and unchecked checkboxes.
If you don’t want to use FontAwesome, then you can also use your custom images as per your requirement.
You can simply get the FontAwesome css from the below url :
https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
Now we will start by creating our structure for the checkboxes:
It’s necessary that you define ‘for’ on the label as our checkboxes will be hidden by default. With the help of label we can identify our checkboxes.
Now we will write some CSS to make the custom design of checkboxes.
.label { position: relative; padding-left: 30px; font-size: 14px; cursor: pointer; } .label:before, .label:after { font-family: FontAwesome; font-size: 20px; position: absolute; left: 0; } /*icon for unchecked checkbox*/ .label:before { content: '\f096'; } /*icon for checked checkbox*/ .label:after { content: '\f046'; max-width: 0; overflow: hidden; opacity: 0.5; transition: all 0.35s; } input[type="checkbox"] { display: none; } input[type="checkbox"]:checked + .label:after { max-width: 25px; opacity: 1; }
You can also modify the above css as per your requirement as I am using the basic properties, Hope you find the above blog useful.
In this was you can create Custom Checkboxes using CSS.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Gaurav Arora
Gaurav is an experienced UI developer with experience and capabilities to build compelling UI's for Web and Mobile Applications.