JSFiddle - React, Tailwind, and code Playground
HTML
<label class="label_radio-STD happy" for="happy3"><input id="happy3" name="q3" type="radio" value="YES"/></label>
<label class="label_radio-STD meh" for="meh3"><input id="meh3" name="q3" type="radio" value="INDIFFERENT"/></label>
<label class="label_radio-STD sad" for="sad3"><input id="sad3" name="q3" type="radio" value="NO"/></label>
<br />
<br />
<label class="label_radio" for="radio0">0<input id="radio0" name="q5" type="radio" value="0"/></label>
<label class="label_radio" for="radio1">1<input id="radio1" name="q5" type="radio" value="1"/></label>
<label class="label_radio" for="radio2">2<input id="radio2" name="q5" type="radio" value="2"/></label>
CSS
.r_on { background: #0F0 !important; }
.label_radio, .r_off{ background: #00F; }
.s_on { background: #F00 !important; }
.label_radio-STD, .s_off{ background:#000; }
label{width:50px; height:50px; overflow:hidden; display:block; cursor:pointer;}
input[type=radio]{display:none;}
JavaScript
function setupLabel() {
if ($('.label_check input').length) {
$('.label_check').each(function() {
$(this).removeClass('c_on');
});
$('.label_check input:checked').each(function() {
$(this).parent('label').addClass('c_on');
});
};
if ($('.label_radio input').length) {
$('.label_radio').each(function() {
$(this).removeClass('r_on');
});
$('.label_radio input:checked').each(function() {
$(this).parent('label').addClass('r_on');
});
};
if ($('.label_radio-STD input').length) {
$('.label_radio-STD').each(function() {
$(this).removeClass('s_on');
});
$('.label_radio-STD input:checked').each(function() {
$(this).parent('label').addClass('s_on');
});
};
};
//do on ready
$('label').click(function() {
setupLabel();
});
setupLabel();