<form class="form flex-center">
		<div class="form-row flex-center">
			<input type="radio" name="gender" id="Male" class="form-input">
			<label for="Male" class="form-label">Male</label>
		</div>
		<div class="form-row flex-center">
			<input type="radio" name="gender" id="Female" class="form-input">
			<label for="Female" class="form-label">Female</label>
		</div>
	</form>
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

.flex-center {
	align-items: center;
	display: flex;
	justify-content: center;
}

.form {
	background: #cccccc;
	height: 100vh;
	width: 100%;
}

.form-row {
	background: #ffffff;
	border-radius: 50px;
	height: 40px;
	margin: 10px;
	overflow: hidden;
	position: relative;
	width: 150px;
}

.form-input {
	-webkit-appearance: none;
	appearance: none;
}

.form-input::before {
	content: '';
	cursor: pointer;
	height: 100%;
	left: 0;
	position: absolute;
	top: 0;
	width: 100%;
}

.form-input:checked::before {
	background: #21209c;
}

.form-input::after {
	content: '';
	cursor: pointer;
	height: 15px;
	border-radius: 50px;
	border: 4px solid #21209c;
	left: 10%;
	position: absolute;
	top: 50%;
	transform: translate(0, -50%);
	width: 15px;
}

.form-input:checked::after {
	border: 4px solid #ffffff;
}

.form-label {
	color: #21209c;
	font-size: 1.1rem;
	margin-left: 10px;
	z-index: 1;
	/*position: absolute; This is an alternative option */
}

.form-input:checked ~ .form-label {
	color: #ffffff;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.