JSFiddle - React, Tailwind, and code Playground

by Onza

HTML

<div ng-app="MyApp">
    <div ng-controller="MyCtrl">
        <h4>{{title}}</h4><br>
        <div class="element">
            <div class="title">Bedrooms ({{bedsModel}})</div>
            <radio-button ng-model="bedsModel" label="1" value="1"></radio-button>
            <radio-button ng-model="bedsModel" label="2" value="2"></radio-button>
            <radio-button ng-model="bedsModel" label="3" value="3"></radio-button>
        </div>
        <div class="element">
            <div class="title">Bathrooms ({{bathsModel}})</div>
            <radio-button ng-model="bathsModel" label="1" value="1"></radio-button>
            <radio-button ng-model="bathsModel" label="2" value="2"></radio-button>
        </div>
    </div>
</div>

CSS

/* General */
.element {
    display: inline-block;
    width: 300px;
    margin-bottom: 20px;
}
.element > .title {
    display: inline-block;
    width: 100px;
}
.element > radio-button {
    display: inline-block;
    width: 100px;
    background: yellow;
}


/* Custom radio button */
.my-radio {
	display: inline-block;
    padding-right: 10px;
}
.my-radio > .radio-button {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 1px solid #b9b9b9;
    border-radius: 50%;
    background: #ffffff;
}
.my-radio > .radio-button > input[type=radio] {
    display: none;
}
.my-radio > .title {
	display: inline-block;
	position: relative;
	top: -1px;
	margin-left: 5px;
}
.my-radio > .title > label {
	display: inline-block;
	padding-top: -5px;
	font-weight: normal;
	font-size: 10px;
	cursor: pointer;
}

.my-radio > .radio-button > input[type=radio] + label span {
    display: inline-block;
    position: relative;
    top: -1px;
    left: 2px;
    border-radius: 50%;
    cursor: pointer;
}
.my-radio > .radio-button > input[type=radio]:checked + label span {
    background-color: #f68124;
}
.my-radio > .radio-button > label > span.radio-checked {
    display: inline-block;
    width: 9px;
    height: 9px;
}

JavaScript

/* Module */
var app = angular.module("MyApp", []);
/* Controller */
app.controller("MyCtrl", ["$scope", function($scope)
{
    $scope.title = "Error with custom radio buttons";
}]);
/* Directive */
app.directive("radioButton", function()
{
    return {
	    restrict: 'E',
		scope: {
			label: '@',
			ngModel: '=',
			value: '@'
		},
		controller: ['$scope', function ($scope)
		{
		    $scope.checked = function()
			{
				return $scope.value === $scope.model;
			};
		}],
		template: '<div class="my-radio">'+
				       '<div class="radio-button">'+
                           '<input type="radio" ng-model="ngModel" value="{{value}}" name="{{value}}" id="{{value}}" />'+
                           '<label for="{{value}}"><span class="radio-checked"></span></label>'+
                       '</div>'+
                       '<div class="title"><label for="{{value}}">{{label}}</label></div>'+
                   '</div>',
		replace: true
	};
});