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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                h1.color
  i.icon.color-bg.color.gradient.
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="&#1057;&#1083;&#1086;&#1081;_1" x="0px" y="0px" viewBox="5.0 -10.0 100.0 135.0" enable-background="new 0 0 100 100" xml:space="preserve" height="100px" width="100px"><path d="M8.5,80.1c0,0.5-0.2,0.9-0.5,1.3l-2.3,2.3c-1,1-1,2.6,0,3.5l7.1,7.1c0.5,0.5,1.1,0.7,1.8,0.7s1.3-0.3,1.8-0.7l2.3-2.3  c0.3-0.3,0.8-0.5,1.3-0.5c1.8,0,3.5-0.7,4.8-2l36.8-36.8l1.8,1.8h0c0.5,0.5,1.1,0.7,1.8,0.7c0,0,0,0,0,0c1.4,0,2.5-1.1,2.5-2.5  c0-0.7-0.3-1.3-0.7-1.8l24.6-24.6c4.9-4.9,4.9-12.8,0-17.7C89,6.3,85.8,5,82.5,5S76,6.3,73.7,8.7L49.1,33.2v0c-1-1-2.6-1-3.5,0  c-1,1-1,2.6,0,3.5l1.8,1.8L10.5,75.3C9.2,76.6,8.5,78.3,8.5,80.1z M77.2,12.2c1.4-1.4,3.3-2.2,5.3-2.2s3.9,0.8,5.3,2.2  c2.9,2.9,2.9,7.7,0,10.6L63.2,47.4L52.6,36.8L77.2,12.2z M11.6,84.9c1.3-1.3,2-3,2-4.8c0-0.5,0.2-0.9,0.5-1.3l36.8-36.8l7.1,7.1  L21.1,85.9c-0.3,0.3-0.8,0.5-1.3,0.5c-1.8,0-3.5,0.7-4.8,2L14.6,89L11,85.4L11.6,84.9z"/></svg>
  span.js-title color palette
  input#hexval.color(type='text')
  
.fan.js-fan

.settings
  a.js-toggle-settings.close(href='#') ✖
  i.input
    label
      strong Start HUE
      input#hue(type='range', min=0, max=360, value=0, step="1")
      output(for='hue').hue-val 0
      
  i.input
    label
      strong Start color
      input#startcolor(type='text', placeholder='HEX, RGB, HSL, Name, HSV etc..')
      
  i.input
    label
      strong Saturation
      input#saturation(type='range', min=1, max=100, value=100, step=1)
      output(for='saturation').saturation-val 100
      
  i.input
    label
      strong Lightness
      input#light(type='range', min=1, max=100, value=75, step=1)
      output(for='light').light-val 75
  
  i.input
    label
      strong Amount of colors
      input#colors(type='range', min=2, max=30, value=24, step="1")
      output(for='colors').colors-val 24
  
  i.input
    label
      strong Color Palette
      input.js-color-type(type='radio', name='colortype', value='huslp', checked=true)
      i HUSLp &nbsp;
    label
      input.js-color-type(type='radio', name='colortype', value='husl')
      i HUSL &nbsp;
    label
      input.js-color-type(type='radio', name='colortype', value='hsl')
      i HSL
    label
      input.js-color-type(type='radio', name='colortype', value='hcl')
      i HCL
  
  i.input.export
    label 
      strong JSON Export
      textarea.js-palette

a.settings-link.js-toggle-settings.color-contrast(href='#').  
  <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="26" height="26" data-icon="cog" viewBox="0.8 -1.6 16.0 21.6"><path d="M7 0l-1 2-.906.313-2.094-.813-1.5 1.5.813 2.094-.313.906-2 1v2l2 1c.1.3.206.606.406.906l-.906 2.094 1.5 1.5 2.094-.813.906.313 1 2h2l1-2c.3-.1.606-.206.906-.406l2.094.813 1.5-1.5-.813-2.094c.1-.3.306-.606.406-.906l1.906-.906v-2l-2-1c-.1-.3-.206-.606-.406-.906l.906-2.094-1.5-1.5-2.094.813-.906-.313-1-2h-2zm1 5c1.7 0 3 1.3 3 3s-1.3 3-3 3-3-1.3-3-3 1.3-3 3-3z"/></svg>



              
            
!

CSS

              
                $black: #212121;
$white: #fff;
$bg: $white;

html, body {
  height: 100%;
  overflow: hidden;
}

.color-contrast {
  color: $black;
  .bg-dark & { 
    color: $white;
  }
}

.color-contrast-bg {
  background-color: $black;
  .bg-dark & { 
    background-color: $white;
  }
}
.color-bg {
  background-color: $bg;
  .bg-dark & {
    background-color: $black;
  }
}
.color,
input[type=text].color{
  color: $bg;
  .bg-dark & {
    color: $black;
  }
}
html {
  transition: background-color 300ms 440ms ease-out;
  &.bg-dark {
    background: lighten($black, 5%);
  }
}
body {
  overflow: hidden;
  font-family: Helvetica, Sans-serif;
}

.fan {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2vh; height: 2vh;
  perspective: 600;
  transition: 450ms transform cubic-bezier(0.370, 0.000, 0.250, 0.980);
}
.fan-page {
  cursor: pointer;
  position: absolute;
  display: flex;
  flex-direction: column;
  height: 40vh; width: 10vh;
  top: -40vh; left: 0;
  box-shadow: 0 0 20px rgba($black,.1);
  transform: translate3d(0,0,0) rotate(0deg);
  transform-origin: 1vh 39vh;
  border-radius: .5vh;
  overflow: hidden;
  transition: 200ms 200ms transform ease-in-out;
  box-sizing: border-box;
}

.fan-color {
  flex-grow: 1;
  width: 100%;
  font-size: 1.3vh;
  span {
    position: relative;
    display: block;
    padding: .5rem;
    transition: 200ms background-color ease-in;
  }
  a, em {
    position: absolute;
    top: 100%; left: 0; right: 0;
    padding: .5rem;
    display: block;
    color: $white;
    text-decoration: none;
    overflow: hidden;
    transition: 200ms color ease-in;
    font-style: normal;
  }
  strong {
    display: block;
  }
}

.settings-link {
  position: absolute;
  top: 1vh; right: 1vh;
  z-index: 20;
  width: 4.25vh; 
  height: 4.25vh;
  svg {
    width: 100%;
    height: 100%;
    display: block;
  }
  path {
    fill: currentColor;
    transition: 200ms fill;
  }
  &:hover {
    path {
      fill: rgba(0,0,0,.6);
    }
  }
}
.settings {
  position: absolute;
  z-index: 100;
  right: 0;
  top: 0;
  background: #212121;
  color: $bg;
  padding: 20px;
  transform: translate(50%,-105%);
  transition: 200ms transform ease-in-out;
  outline: 5px solid rgba(#000,.25);
  .show-settings & {
    transform: translate(-1vh,1vh);
  }
  .close {
    text-decoration: none;
    position: absolute; 
    top: 5px; right: 8px;
    color: $white;
  }
}

.input {
  display: block;
  font-size: 12px;
  font-style: normal;
  strong {
    margin-top: 5px;
    margin-bottom: 3px;
    display: block;
  }
}


h1 {
  position: absolute;
  top: 2vh; left: 2vh;
  font-size: 2.5vh;
  line-height: 1;
  margin: 0;
  vertical-align: middle;
  font-weight: 300;
  overflow: hidden;
  .icon {
    position: relative;
    vertical-align: middle;
    border-radius: 100%;
    width: 2em; height: 2em;
    overflow: hidden;
    display: flex;
    float: left;
    flex-direction: column;
    border: .2em solid currentColor;
  }
  span {
    position: relative;
    flaot: left;
    padding-left: 1.1vh;
    vertical-align: middle;
    top: 0em;
    font-size: 1.25em;
  }
  #hexval {
    position: absolute;
    top: 1.5em; 
    left: 3.5em;
    display: inline-block;
    border: none;
    background: transparent;
    outline: none;
    font-size: .75em;
  }
  svg {
    position: absolute;
    top: 54%; left: 53%;
    transform: translate(-50%, -50%);
    width: 1.2em; height: 1.2em;
    path {
      fill: currentColor;
    }
  }
}

textarea, input[type=text] {
  color: $black;
  padding: 0.2rem;
  width: 100%;
  box-sizing: border-box;
}

textarea {
  height: 0;
  opacity: 0;
  border: none;
  &:focus {
    height: 5rem;
    opacity: 1;
  }
}

.export {
  display: block;
  padding-top: 0.5rem;
  
  strong {
    padding: 0.25rem 0.5rem; 
    background: white;
    color: black;
    border-radius: 3px;
    cursor: pointer;
    &:hover {
      opacity: .9;
    }
  }
}


              
            
!

JS

              
                var $body, i, $d, cl, $fan, pages, $active, currentRot, colorVariations,
    max = 24, selectedColorVariation = 0, $gradient, $title, currentColors, $export;

colorVariations = [
  {
    startHue: 0,
    light: 75,
    saturation: 100,
    type: 'huslp'
  }
];

$body = $('body');
$fan = $('.js-fan');
$title = $('.js-title');
$gradient = $('.gradient');
$d = $(document);
$export = $('.js-palette');

function convertCategories(pal) {
  pal = pal || 'hsl';
  var newCategories = {};
  for(var cetegory in colorCategories) {
    if(pal == 'husl'){
      var hsl = tinycolor(colorCategories[cetegory]).toHsl();
      newCategories[cetegory] = $.husl.toHex(hsl.h, hsl.s * 100, hsl.l * 100);
    }else if(pal == 'huslp'){
      var hsl = tinycolor(colorCategories[cetegory]).toHsl();
      newCategories[cetegory] = $.husl.p.toHex(hsl.h, hsl.s * 100, hsl.l * 100);
    }else{
      newCategories[cetegory] = colorCategories[cetegory];  
    }
  }
  return newCategories;
}

createPalette(max, colorVariations[0]);

function createPalette (max, color) {
  var categories,getCatNames, startHue, s, l, type, currentColors = [], previousColor;
  
  startHue = color.startHue;
  s = color.saturation;
  l = color.light;
  type = color.type;
  categories = convertCategories(type);
  getCatNames = nearestColor.from(categories);
  
  pages = []; currentRot = 0;
  
  max = parseInt(max); startHue = parseInt(startHue), s = parseInt(s), l = parseInt(l);
  
  if ( $('.fan').length && colorVariations.length === 1 ) {
    $('.fan').empty();
  }
  
  for (i = 0; i < max; i++) {
    var hsl = [(startHue + (i / max) * 360) % 360, s, l];
    var $page = $('<div />', {class: 'fan-page js-page'});
    var $color = $('<div />', {class: 'fan-color'});

    var color, colorCSS, rotation, scale, colorName, colorCategory;
    
    pages.push($page);
    
    switch(type) {
      case 'hcl':
        //color = chroma.cubehelix((startHue / 360) * 2, 2, hsl[0]/100, 1, hsl[2]/100);
        //color = chroma('hsl(' + hsl[0] + ',' + hsl[1] + '%,' + hsl[2] + '%)').hex();
        var c = chroma.cubehelix().start(startHue).rotations(-0.5).gamma(hsl[1]/100).lightness([Math.max(.1,1 - (hsl[2]/100)), hsl[2]/100]);
        color = 'red'
        color = c(hsl[0]/360).hex();
        break;
      case 'huslp':
        color = $.husl.p.toHex.apply(this, hsl);
        break;
      case 'husl':
        color = $.husl.toHex.apply(this, hsl);
        break;
      default:
        color = tinycolor( 'hsl(' + hsl[0] + ',' + hsl[1] + '%,' + hsl[2] + '%)' ).toHexString();
        break;
    }
    
    colorName = getClosestNamedColor( color ).name;
    colorCategory = getCatNames( color ).name;
    
    rotation = (i + 1) * (360 / max);
    scale = i * 2;
    $page.css({
      "transform": "translate3d(0,0," + scale + "px) rotate(" + rotation + "deg)"
    }).data('rotation', rotation).data('scale', scale).data('color', color).data('colorname', colorName);
    
    if( previousColor ) {
      $page.data('previouscolor', previousColor);
    }
    
    if( i+1 == max ){
      $fan.find('js-page:eq(0)').data('previouscolor', color);
    }
    
    previousColor = color;
    
    currentColors.push({name: colorName, color: color, category: colorCategory});
    
    $color.css({
      "color": color,
      "background-color": color
    });
    $color.html("<span class='color-bg'><strong>" + color.toUpperCase() + "</strong><em class='color'>" + colorName + "</em></span>");
    
    $page.append($color);
    $fan.append($page);
  }
  
  $gradient.each(function(){
    var $that = $(this);
    $gradient.find('.fan-color').remove();
    pages.forEach(function($page){
      var $color = $('<div />', {class: 'fan-color'});
      $color.css('background-color', $page.data('color') );
      $that.append($color)
    });
  });
  
  $export.html(JSON.stringify(currentColors));
  $body.append($fan);
  $active = pages[pages.length - 1];
}

$d.on('mouseenter', '.js-page', function(){
  var $this = $(this);
  var match = false, before, after;
  
  pages.forEach(function($el, i){
    var data = $el.data();
    if( $el[0] === $this[0] ){
      $el.css({
        "transform": "translate3d(0,0," + (parseInt(data.scale) + 50) + "px) rotate(" + parseInt(data.rotation) + "deg)"
      });
      match = i;
    }
  });
  
  before = pages[match - 1] ? pages[match - 1] : pages[pages.length - 1];
  after = pages[match + 1] ? pages[match + 1] : pages[0];
  
  before.css({
    "transform": "translate3d(0,0," + parseInt(before.data().scale) + "px) rotate(" + (parseInt(before.data().rotation) - 5) + "deg)"
  });
  after.css({
    "transform": "translate3d(0,0," + parseInt(after.data().scale) + "px) rotate(" + (parseInt(after.data().rotation) + 5) + "deg)"
  });
});


$d.on('mouseleave', '.js-page', function(){
  pages.forEach(function($el, i){
    var data = $el.data();
    $el.css({
      "transform": "translate3d(0,0," + parseInt(data.scale) + "px) rotate(" + parseInt(data.rotation) + "deg)"
    });
  });
});

$d.on('click', '.js-page', function(){
  var $this = $(this);
  
  if($this[0] === $active[0]) {
    $fan.css("transform", "rotate(0deg)");
    $('html').css('background-color', '#fff' );
    $('#hexval').val('#fff');
    $active = pages[pages.length - 1];
    currentRot = 0;
    $title.html("");
  } else {
    var currentRot = parseInt($active.data().rotation);
    var newRot = parseInt($this.data().rotation);
    $fan.css("transform", "rotate(" + -newRot + "deg)");
    $('html').css({
      'background-color': $this.data().color,
    });
    
    //$('html')[0].style['background-image'] = '-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, '+ $this.data().color +'), color-stop(100%, '+$this.data().previouscolor+'))';

    $active = $this;
    $title.html($this.data('colorname'));
    $('#hexval').val( $this.data().color ).focus().select();
  }
  
});

$d.on('change', '#hue', function(){
  var startHue = colorVariations[selectedColorVariation].startHue = parseInt( $(this).val() );
  createPalette(max, colorVariations[selectedColorVariation]);
  $('.hue-val').html(startHue)
});

$d.on('change', '#colors', function(){
  max = $(this).val();
  createPalette(max, colorVariations[selectedColorVariation]);
  $('.colors-val').html(max);
});

$d.on('change', '#light', function(){
  var light = colorVariations[selectedColorVariation].light = parseInt( $(this).val() );
  createPalette(max, colorVariations[selectedColorVariation]);
  
  if(parseInt(light) > 75) {
    $('html').addClass('bg-dark');
  }else{
    $('html').removeClass('bg-dark');
  }
  $('.light-val').html(light);
});

$d.on('change', '#saturation', function(){
  var saturation = colorVariations[selectedColorVariation].saturation = parseInt( $(this).val() );
  createPalette(max, colorVariations[selectedColorVariation]);
  $('.saturation-val').html(saturation);
});

$d.on('click', '.js-toggle-settings', function(){
  $body.toggleClass('show-settings');
});

$d.on('change', '.js-color-type', function(){
  var type = colorVariations[selectedColorVariation].type = $(this).val();
  createPalette(max, colorVariations[selectedColorVariation]);
});

var timer;

$d.on('keyup', '#startcolor', function(){
  var $this = $(this), val, hsl;
  val = $this.val();
  if( tinycolor( val ).isValid() ) {
    clearTimeout(timer);
    hsl = tinycolor( val ).toHsl();
    colorVariations[selectedColorVariation].startHue = hsl.h;
    $('#hue').val(hsl.h);
    colorVariations[selectedColorVariation].saturation = (hsl.s * 100) || 1;
    $('#saturation').val((hsl.s * 100) || 1);
    colorVariations[selectedColorVariation].light = (hsl.l * 100) || 1;
    $('#light').val((hsl.l * 100) || 1);
    
    setTimeout(function(){
      createPalette(max, colorVariations[selectedColorVariation]);
    },500);
  }
});
              
            
!
999px

Console