Awesome Custom Radio Buttons using only HTML & CSS
Tags: css, html, radiobutton, customradiobutton
Published: 2020-12-26 16:32:40

Hello readers, Today in this blog you'll learn how to create Awesome Custom Radio Buttons using only HTML & CSS. Earlier I've shared a blog on <a href="https://www.codingnepalweb.com/2020/08/custom-checkbox-design-using-only-html-css.html">how to create a Custom Checkbox or Toggle Switch On/Off</a> and now it's time to create radio buttons.

A radio button or option button is a graphical control element that allows the user to select one of many given choices. Radio buttons are so-called because they work as the channel presets on radios. A radio button in HTML can be defined using the <input type="radio"> tag.

In this program [Awesome Custom Radio Buttons], there are four options on the webpage and you can select only one option. When you select any of those options, that selected option background color will be black and there is also shown a circle effect to inform the user that, the particular option is selected. This is purely based on HTML & CSS only.

You can copy the codes from the given boxes or download the code files from the given link but I recommend you to download the source code files instead of copying codes. <a href="https://www.codingnepalweb.com/2020/09/custom-radio-buttons-using-html-css.html">Click here to download code files.</a>

####You might like this:
<a href="https://www.codingnepalweb.com/2020/08/custom-checkbox-design-using-only-html-css.html" target="_blank">Custom Checkbox Switch Design</a>
<a href="https://www.codingnepalweb.com/2020/05/cool-glowing-effect-on-css-buttons.html" target="_blank">Pure CSS Glowing Effect on Buttons</a>
<a href="https://www.codingnepalweb.com/2020/05/animated-3d-flip-buttons-using-html-css.html" target="_blank">Animated CSS 3D Flip Buttons Hover</a>
<a href="https://www.codingnepalweb.com/2020/12/todo-list-app-using-html-css-javascript.html" target="_blank">Todo App List with Localhost JavaScript</a>

######HTML CODE:
```
<!DOCTYPE html>
<!-- Created By CodingNepal -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- Somehow I got an error, so I comment the title, just uncomment to show -->
    <!-- <title>Custom Radio Buttons | CodingNepal</title> -->
    <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="wrapper">
    <div class="title">Select your option</div>
    <div class="box">
      <input type="radio" name="select" id="option-1">
      <input type="radio" name="select" id="option-2">
      <input type="radio" name="select" id="option-3">
      <input type="radio" name="select" id="option-4">
      <label for="option-1" class="option-1">
        <div class="dot"></div>
        <div class="text">Gamer</div>
      </label>
      <label for="option-2" class="option-2">
        <div class="dot"></div>
        <div class="text">YouTuber</div>
      </label>
      <label for="option-3" class="option-3">
        <div class="dot"></div>
        <div class="text">Student</div>
      </label>
      <label for="option-4" class="option-4">
        <div class="dot"></div>
        <div class="text">Developer</div>
      </label>
    </div>
  </div>

</body>
</html>
```

######CSS CODE:
```
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap');
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}
html,body{
  display: grid;
  height: 100%;
  place-items: center;
}
.wrapper{
  width: 350px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 5px 5px 30px rgba(0,0,0,0.2);
}
.wrapper .title{
  color: #fff;
  line-height: 65px;
  text-align: center;
  background: #333;
  font-size: 25px;
  font-weight: 500;
  border-radius: 10px 10px 0 0;
}
.wrapper .box{
  padding: 20px 30px;
  background: #fff;
  border-radius: 10px;
}
.wrapper .box label{
  display: flex;
  height: 53px;
  width: 100%;
  align-items: center;
  border: 1px solid lightgrey;
  border-radius: 50px;
  margin: 10px 0;
  padding-left: 20px;
  cursor: default;
  transition: all 0.3s ease;
}
#option-1:checked ~ .option-1,
#option-2:checked ~ .option-2,
#option-3:checked ~ .option-3,
#option-4:checked ~ .option-4{
  background: #333;
  border-color: #333;
}
.wrapper .box label .dot{
  height: 20px;
  width: 20px;
  background: #d9d9d9;
  border-radius: 50%;
  position: relative;
  transition: all 0.3s ease;
}
#option-1:checked ~ .option-1 .dot,
#option-2:checked ~ .option-2 .dot,
#option-3:checked ~ .option-3 .dot,
#option-4:checked ~ .option-4 .dot{
  background: #fff;
}
.box label .dot::before{
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(2);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transition: all 0.3s ease;
}
#option-1:checked ~ .option-1 .dot::before,
#option-2:checked ~ .option-2 .dot::before,
#option-3:checked ~ .option-3 .dot::before,
#option-4:checked ~ .option-4 .dot::before{
  background: #333;
  transform: translate(-50%, -50%) scale(1);
}
.wrapper .box label .text{
  color: #333;
  font-size: 18px;
  font-weight: 400;
  padding-left: 10px;
  transition: color 0.3s ease;
}
#option-1:checked ~ .option-1 .text,
#option-2:checked ~ .option-2 .text,
#option-3:checked ~ .option-3 .text,
#option-4:checked ~ .option-4 .text{
  color: #fff;
}
.wrapper .box input[type="radio"]{
  display: none;
}
```

Don't forget to visit our blog for more related designs - https://www.codingnepalweb.com