Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class='container'>
  <div class='ul'>
    <div class='li l1-1' id='one'>
      <p class='text'>One</p>
      <div class='cr-wrap cr-w-1'>
        <div class='cr'>
          <div class='crx crx-1'></div>
        </div>     
      </div>
    </div>
    <div class='li l1-2' id='two'>
      <p class='text'>Two</p>
      <div class='cr-wrap cr-w-2'>
        <div class='cr'>
          <div class='crx crx-2'></div>
        </div>
      </div>
    </div>
    <div class='li l1-3' id='three'>
      <p class='text'>Three</p>
      <div class='cr-wrap cr-w-3'>
        <div class='cr'>
          <div class='crx crx-3'></div>
        </div>
      </div>
    </div>
  </div>
</div>

<!-- References Dribbble / Twitter -->
<div class='cs-ref'>
  <a class="cs-dribbble" href="https://dribbble.com/shots/10344240-UI-Radio-Button" target="_blank">
    <div id='svgDribbble'></div>
  </a>
  <a class="cs-twitter" target="_blank" href="https://twitter.com/CosWiSe">
    <div id='svgTwitter'></div>
  </a>
</div>
              
            
!

CSS

              
                // IMPORT
@import url('https://fonts.googleapis.com/css?family=Muli:300,400,700,900');

// VARIABLES 
// $canvasBg: #f7f7f7; Grey
$canvasBg: #f1f3f9; // Bright #d5dbed

$textC: #333333;
$col1: #ff8c69;
$col2: ff696c;
$col3: #1462ff;
$col4: #f0f1f5;

$colFb: #4fa7ff;

$svgC: rgba(#929cd0, .8);
// $shadowC: #d1d4e1;
$shadowC: #d5dbed;
$shadowDef: 0 3px 20px -3px $shadowC;
$shadowDefTwo: 0 6px 30px -10px $shadowC;

// PLACEHOLDERS
%no-selection {
  // No selection
  -webkit-user-select: none;  
  -moz-user-select: none;     
  -ms-user-select: none;      
  user-select: none;    
}

// DEFAULT
html {
  display: flex;
  justify-content: center;
  align-items: center;
  background: $canvasBg;
  height: 100vh;
  font-family: 'Muli', Arial, sans-serif;
  > * 
  {
    @extend %no-selection;
  }
}

// SVGs
#dribbble {
  position: fixed;
  display: block;
  right: 70px;
  bottom: 16px;
  svg {
    display: block;
    width: 76px;
    height: 24px;
    fill: $svgC;
  }
}
#twitter {
  position: fixed;
  display: block;
  right: 25px;
  bottom: 11px;
  svg {
    width: 24px;
    height: 24px;
    fill: $svgC;
  }
}

// NEW CODE HERE


// Variables
$sW: 150px;
$sH: 200px;

// Placeholdders
%center {
  display: flex;
  justify-content: center;
  align-items: center;
}


// Container
.container {
  @extend %center;
  width: auto;
  height: auto;
  box-sizing: border-box;
  padding: 30px 20px;
  background: #fff;
  box-shadow: 0 8px 22px -6px rgba($shadowC, .9);
  border-radius: 12px;
}

// List
.ul {
  @extend %center;
  flex-direction: column;
  width: $sW/1.2;
  height: auto;
  padding: 0;
  & > .li:nth-child(2) {
    margin: 20px 0;
  }
}

.li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: $sW/1.35;
  height: 30px;
  cursor: pointer;
  position: relative;
  .text {
    font-size: 1.1em;
  }
}

// Circles
.cr {
  @extend %center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba($col3, .8);
  overflow: hidden;
  position: relative;
  z-index: 3;
}

.crx {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba($col3, .8);
  transform: translatex(-19px);
}

// CR Behaviour Post Selection
// Top
.crx-top-in {
  animation: fromTopIn 479ms linear forwards 129ms;
}
.crx-top-out {
  animation: fromTopOut 99ms linear forwards;
}

//Bottom
.crx-bottom-out {
  animation: fromBottomOut 99ms linear forwards;
} 
.crx-bottom-in {
  animation: fromBottomIn 479ms linear forwards 129ms;
}


// From Top
@keyframes fromTopIn {
  0% {
    transform: translatey(-14px) scale(1.5, .6); // Stage 0
  }
  33.2% {
    transform: translatey(-5px) scale(1.4, .8); // Stage 1
  }
  49.8% {
    transform: translatey(0px) scale(.9, 1.2); // Stage 2
  }
  66.4% {
    transform: translatey(6px) scale(1.4, .7); // Stage 3
  }
  73% {
    transform: translatey(6px) scale(1.4, .7); // Stage 4
  }
  83% {
    transform: translatey(-1px) scale(.9, 1.1); // Stage 5
  }
  100% {
    transform: translatey(0) scale(1, 1); // Stage 6
  }
}
@keyframes fromTopOut {
  0% {
    transform: translatey(0) scale(1, 1); // Stage 0
  }
  25% {
    transform: translatey(1px) scale(.9, 1.1); // Stage 1
  }
  50% {
    transform: translatey(-6px) scale(1.4, .7); // Stage 2
  }
  75% {
    transform: translatey(-7px) scale(1.6, .4); // Stage 3
  }
  100% {
    transform: translatey(-14px) scale(1.6, .4); // Stage 4
  }
}

// From Bottom
@keyframes fromBottomIn {
  0% {
    transform: translatey(14px) scale(1.5, .6); // Stage 0
  }
  33.2% {
    transform: translatey(5px) scale(1.4, .8); // Stage 1
  }
  49.8% {
    transform: translatey(0px) scale(.9, 1.2); // Stage 2
  }
  66.4% {
    transform: translatey(-6px) scale(1.4, .7); // Stage 3
  }
  73% {
    transform: translatey(-6px) scale(1.4, .7); // Stage 4
  }
  83% {
    transform: translatey(1px) scale(.9, 1.1); // Stage 5
  }
  100% {
    transform: translatey(0) scale(1, 1); // Stage 6
  }
}
@keyframes fromBottomOut {
  0% {
    transform: translatey(0) scale(1, 1); // Stage 0
  }
  25% {
    transform: translatey(-1px) scale(.9, 1.1); // Stage 1
  }
  50% {
    transform: translatey(6px) scale(1.4, .7); // Stage 2
  }
  75% {
    transform: translatey(7px) scale(1.6, .4); // Stage 3
  }
  100% {
    transform: translatey(14px) scale(1.6, .4); // Stage 4
  }
}

// Circles Feedback
.cr-wrap {
  @extend %center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: transparent;
  position: absolute;
  right: -1px;
  // top: 2px;

}
.cr-w-fb {
  &:before {
    content: '';
    border-radius: 50%;
    background: $colFb;
    position: absolute;
    z-index: 1;
    width: 10px;
    height: 10px;
    opacity: 1;
    animation: feedback 699ms ease-out forwards;
  }
}

@keyframes feedback {
  0% {
    width: 10px;
    height: 10px;
    opacity: 1;
  }
  30% {
    opacity: 1;
  }
  80% {

    opacity: 0;
  }
  100% {
    opacity: 0;
    width: 10px*5;
    height: 10px*5;
  }
}
              
            
!

JS

              
                // ICONS CALLBACK
feather.replace();

// SVGs
$('#svgDribbble').load('https://s3-us-west-2.amazonaws.com/s.cdpn.io/373860/references.html #dribbble');
$('#svgTwitter').load('https://s3-us-west-2.amazonaws.com/s.cdpn.io/373860/references.html #twitter');

/*

https://dribbble.com/shots/4214518-Radio-button

ADD NEW ICONS
Take it from
https://feathericons.com/

And then replace the icon name in data-father.
<i data-feather="circle"></i>

*/

// NEW CODE HERE
var cr1 = true;
var cr2 = false;
var cr3 = false;

var crx1 = $('.crx-1');
var crx2 = $('.crx-2');
var crx3 = $('.crx-3');


// Default
if (cr1 == false) {
  crx1.removeClass('crx-top-in');
} else if (cr1 == true) {
  setTimeout(function() {
    crx1.addClass('crx-top-in');
  }, 1000);
}

if (cr2 == false) {
  crx2.removeClass('crx-top-in');
}

if (cr3 == false) {
  crx3.removeClass('crx-top-in');
}



// INTERACTIONS

// Dot
// One
$('#one').on('click', function() {
  cr1 = true;


  if (cr2 == false && cr3 == false) {
    crx1.addClass('crx-top-in');

    console.log('CR1 ON')
  } else if (cr2 == true && cr3 == false) {
    crx2.addClass('crx-top-out');
    crx1.addClass('crx-bottom-in');

    // Feedback
    $('.cr-w-1').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-1').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx2.removeClass('crx-top-in');
      crx2.removeClass('crx-bottom-in');
      crx2.removeClass('crx-bottom-out');
      // crx2.removeClass('crx-top-out');
    }, 0);

    cr2 = false;
    cr3 = false;

  } else if (cr2 == false && cr3 == true) {
    crx3.addClass('crx-top-out');
    crx1.removeClass('crx-bottom-out');
    crx1.addClass('crx-bottom-in');

    // Feedback
    $('.cr-w-1').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-1').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx3.removeClass('crx-top-in');
      crx3.removeClass('crx-top-out');
      crx2.removeClass('crx-bottom-out');
    }, 399);

    cr2 = false;
    cr3 = false;

  } else {
    crx1.removeClass('crx-top-in');
    console.log('CR1 OFF')
  }
  return cr2;
});

// Two
$('#two').on('click', function() {
  cr2 = true;


  if (cr1 == false && cr3 == false) {
    crx2.addClass('crx-top-in');

    console.log('CR2 ON')
  } else if (cr1 == true && cr3 == false) {
    crx2.removeClass('crx-top-out');
    crx1.addClass('crx-bottom-out');
    crx2.addClass('crx-top-in');

    // Feedback
    $('.cr-w-2').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-2').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx1.removeClass('crx-top-in');
      crx1.removeClass('crx-bottom-in');
      // crx1.removeClass('crx-bottom-out');
    }, 0);

    cr1 = false;
    cr3 = false;

  } else if (cr1 == false && cr3 == true) {
    crx3.addClass('crx-top-out');
    crx2.addClass('crx-bottom-in');

    // Feedback
    $('.cr-w-2').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-2').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx3.removeClass('crx-top-in')
      crx3.removeClass('crx-top-out')
      crx2.removeClass('crx-bottom-out');
      crx1.removeClass('crx-bottom-out');
    }, 399);

    cr1 = false;
    cr3 = false;

  } else {
    crx2.removeClass('crx-top-in');
    console.log('CR2 OFF')
  }
  return cr2;
});

// Three
$('#three').on('click', function() {
  cr3 = true;


  if (cr1 == false && cr2 == false) {
    crx1.addClass('crx-top-in');

    console.log('CR1 ON')
  } else if (cr2 == true && cr1 == false) {
    crx2.addClass('crx-bottom-out');
    crx3.addClass('crx-top-in');

    // Feedback
    $('.cr-w-3').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-3').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx2.removeClass('crx-top-in');
      crx2.removeClass('crx-bottom-in');
      crx2.removeClass('crx-top-out');
      crx1.removeClass('crx-bottom-out');
    }, 0);

    cr1 = false;
    cr2 = false;

  } else if (cr2 == false && cr1 == true) {
    crx1.addClass('crx-bottom-out');
    crx3.addClass('crx-top-in');

    // Feedback
    $('.cr-w-3').addClass('cr-w-fb');
    setTimeout(function() {
      $('.cr-w-3').removeClass('cr-w-fb');
    },799);

    setTimeout(function() {
      crx1.removeClass('crx-top-in');
      crx1.removeClass('crx-bottom-in');
      // crx1.removeClass('crx-bottom-out');
    }, 0);

    cr1 = false;
    cr2 = false;

  } else {
    crx1.removeClass('crx-top-in');
    console.log('CR1 OFF')
  }
  return cr2;
});


              
            
!
999px

Console