Skip to content

Instantly share code, notes, and snippets.

@i5on9i
Created April 28, 2018 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i5on9i/d2ebe71f39402c9cc1c9ead78f760b02 to your computer and use it in GitHub Desktop.
Save i5on9i/d2ebe71f39402c9cc1c9ead78f760b02 to your computer and use it in GitHub Desktop.
/**
<label className="radio_label">
<input type="radio"
value={item.value}
checked={item.value === this.state.selectedValue}
onChange={this.onOptionClick.bind(this)} />
<span className="checkmark"></span>
{item.label}
</label>
*/
:global(.radio_label){
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;
/* Hide the browser's default radio button */
input {
opacity: 0;
}
/* Create a custom radio button */
:global(.checkmark) {
/* Create the indicator (the dot/circle - hidden when not checked) */
&:after {
content: "";
position: absolute;
display: none;
/* Style the indicator (dot/circle) */
top: 9px;
left: 9px;
width: 22px;
height: 22px;
// border-radius: 50%;
background: black;
}
position: absolute;
top: 0;
left: 0;
height: 40px;
width: 40px;
background-color: #eee;
}
/* On mouse-over, add a grey background color */
&:hover input ~ :global(.checkmark) {
background-color: #ffffff;
}
/* When the radio button is checked, add a blue background */
& input:checked ~ :global(.checkmark) {
background-color: #ffffff;
}
/* Show the indicator (dot/circle) when checked */
& input:checked ~ :global(.checkmark):after {
display: block;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment