Convert Radio Option to Button Using Only CSS

In this short tutorial I’d like to show how you can convert this:

To this using only CSS!

In this example I’ll use HTML & CSS and at the end of this post you’ll find the live example where I applied this method to Gravity Form. 

HTML:

				
					<div class="radio-toolbar">
    <input type="radio" id="radioApple" name="radioFruit" value="apple" checked>
    <label for="radioApple">Apple</label>

    <input type="radio" id="radioBanana" name="radioFruit" value="banana">
    <label for="radioBanana">Banana</label>

    <input type="radio" id="radioOrange" name="radioFruit" value="orange">
    <label for="radioOrange">Orange</label> 
</div>
				
			

CSS:

				
					.radio-toolbar input[type="radio"] {
  opacity: 0;
  position: fixed;
  width: 0;
}

.radio-toolbar label {
    display: inline-block;
    background-color: #ddd;
    padding: 10px 20px;
    font: 16px sans-serif, Arial;
    border: 2px solid #444;
    border-radius: 4px;
}

.radio-toolbar label:hover {
  background-color: #dfd;
}

.radio-toolbar input[type="radio"]:focus + label {
    border: 2px dashed #444;
}

.radio-toolbar input[type="radio"]:checked + label {
    background-color: #bfb;
    border-color: #4c4;
}
				
			

End!

Example 1:

Example 2:

Here in this example, I’ve applied the same method on Gravity Form radio options: