JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
</head>
<body>
<div class="h2">
Кастомный чекбокс
</div>
<div class="Elements__item">
<div class="Elements__checkbox">
<label class="mark">One
<input type="checkbox" checked="checked">
<span class="checkmark"></span>
</label>
<label class="mark">Two
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="mark">Three
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="mark">Four
<input type="checkbox">
<span class="checkmark"></span>
</label>
</div>
</div>
<div class="h2">
Кастомный радиобаттон
</div>
<div class="Elements__item">
<div class="Elements__radio">
<label class="radiomark">One
<input type="radio" checked="checked" name="radio">
<span class="radiocheck"></span>
</label>
<label class="radiomark">Two
<input type="radio" name="radio">
<span class="radiocheck"></span>
</label>
<label class="radiomark">Three
<input type="radio" name="radio">
<span class="radiocheck"></span>
</label>
<label class="radiomark">Four
<input type="radio" name="radio">
<span class="radiocheck"></span>
</label>
</div>
</div>
</body>
</html>
CSS
/*
CHECK BOX
*/
.mark {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.mark input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
}
.mark:hover input ~ .checkmark {
background-color: #ccc;
}
.mark input:checked ~ .checkmark {
background-color: #330080;
}
.checkmark:after {
content: "";
position: absolute;
opacity: 0;
}
.mark input:checked ~ .checkmark:after {
opacity: 1;
border-width: 0 3px 3px 0;
left: 8px;
top: 5px;
}
.mark .checkmark:after {
left: 0px;
top: 0px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
transition:border-right-width 0.25s ease-in-out, border-bottom-width 0.25s ease-in-out;
}
/*
RADIO BUTTON
*/
.radiomark {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.radiomark input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
.radiocheck {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 50%;
}
.radiomark:hover input ~ .radiocheck {
background-color: #ccc;
}
.radiomark input:checked ~ .radiocheck {
background-color: #330080;
}
.radiocheck:after {
content: "";
position: absolute;
opacity: 0;
}
.radiomark input:checked ~ .radiocheck:after {
opacity: 1;
width: 8px;
height: 8px;
}
.radiomark .radiocheck:after {
top: 9px;
left: 9px;
width: 0;
height: 0;
...