Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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 id="colorContainer">
<h1>HSLA Dials</h1>
<svg xmlns="http://www.w3.org/2000/svg" width="1300" height="300" viewBox="0 0 650 150">
   <circle class="base" r="75" cx="70" cy="80" />
  <circle class="base" r="75" cx="240" cy="80" />
  <circle class="base" r="75" cx="410" cy="80" />
  <circle class="base" r="75" cx="580" cy="80" />
  <g id="HueDial">
    <path d="M70.83,10V17H69.17V10h1.66Zm34.89,9.84-3.52,6.12-1.43-.83L104.28,19l1.44.83ZM131,45.85,125,49.38l-.83-1.44,6.09-3.53.83,1.44Zm9,35.29h-7V79.47h7v1.67Zm-9.79,35.07-6.09-3.53.83-1.45,6.08,3.53-.82,1.45ZM9,114.76l6.09-3.53.83,1.45-6.09,3.53L9,114.76ZM0,79.47H7v1.67H0V79.47ZM9.79,44.41l6.09,3.53-.83,1.44L9,45.85l.83-1.44ZM35.72,19l3.51,6.11-1.43.84-3.52-6.12.29-.17h0l.35-.2.8-.46ZM139.31,90l-3.48-.46.13-1,3.48.46-.13,1ZM.56,89,4,88.5l.13,1L.69,90,.56,89ZM2.27,98l3.39-.91.26,1L2.53,99l-.26-1ZM14.78,37.07l2.79,2.15L17,40l-2.79-2.15.61-.8Zm119.67,70.59-3.24-1.35.38-.93,3.25,1.35-.39.93ZM52.37,12.22l.9,3.41-1,.26-.91-3.41,1-.26ZM97.24,15.5l-1.35,3.26L95,18.37l1.35-3.26.92.39Zm-35.88-5,.46,3.5-1,.13-.46-3.5,1-.13Zm27.23,2-.91,3.41-1-.26.91-3.41,1,.26ZM2.53,61.6l3.39.92-.26,1-3.39-.92.26-1Zm11.65,61.1L17,120.55l.61.8-2.79,2.15-.61-.8ZM113,24.79l-2.14,2.8-.79-.61,2.14-2.8.79.61ZM5.53,52.91l3.25,1.35-.39.93L5.15,53.84l.38-.93Zm74.1-42.29-.46,3.5-1-.13.46-3.5,1,.13Zm58.09,51.94-3.4.92-.25-1,3.39-.92.26,1ZM137.46,99l-3.39-.92.25-1,3.4.91-.26,1Zm-18.33,31.42-2.48-2.5.71-.71,2.48,2.5-.71.71ZM139.44,71.6l-3.48.46-.13-1,3.48-.46.13,1ZM.69,70.6l3.48.47-.13,1L.56,71.6l.13-1Zm124.53,52.92-2.79-2.15.61-.8,2.79,2.15-.61.8ZM27.78,24.18,29.92,27l-.79.6L27,24.79l.79-.61Zm15.89-9.07L45,18.38l-.92.38L42.75,15.5l.92-.39ZM5.15,106.75,8.4,105.4l.38.93-3.25,1.35-.38-.93ZM125.82,37.87,123,40l-.61-.79,2.79-2.15.61.8Zm9,16-3.25,1.35-.38-.92,3.25-1.36.38.93ZM20.86,30.2l2.48,2.5-.71.71-2.48-2.5.71-.71Zm99,.71-2.48,2.49-.71-.71,2.48-2.49.71.71ZM20.17,129.66l2.48-2.5.71.71-2.49,2.5Z" fill="#999"/>
    <g class="hue dial">
      <path d="M70,140.05A60.49,60.49,0,1,0,9.52,79.57,60.6,60.6,0,0,0,70,140.05Z" fill="#4d4d4d" fill-rule="evenodd"/>
      <path d="M70,24.07a55.42,55.42,0,0,1,46.08,24.57H23.91A55.45,55.45,0,0,1,70,24.07Z" fill="#ccc" fill-rule="evenodd"/>
      <path d="M115.48,47.76c.2.29.41.58.6.88H23.91c.2-.3.41-.59.61-.88Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <path d="M70,24.07a55.5,55.5,0,1,1-55.5,55.5A55.5,55.5,0,0,1,70,24.07Zm0,.73a54.77,54.77,0,1,0,54.77,54.77A54.77,54.77,0,0,0,70,24.8Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <circle cx="70" cy="29.49" r="2.15" fill="#333"/>
      <text transform="translate(70 86)">HUE</text>
    </g>
  </g>
  <g id="SaturationDial">
    <path d="M240.83,10V17h-1.66V10h1.66Zm34.89,9.84-3.52,6.12-1.43-.83L274.28,19l1.44.83ZM301,45.85,295,49.38l-.83-1.44,6.09-3.53.83,1.44Zm9,35.29h-7V79.47h7v1.67Zm-9.79,35.07-6.09-3.53.83-1.45,6.08,3.53-.82,1.45ZM179,114.76l6.09-3.53.83,1.45-6.09,3.53-.83-1.45Zm-9-35.29h7v1.67h-7V79.47Zm9.79-35.06,6.09,3.53-.83,1.44L179,45.85l.83-1.44ZM205.72,19l3.51,6.11-1.43.84-3.52-6.12.29-.17h0l.35-.2.8-.46ZM309.31,90l-3.48-.46.13-1,3.48.46-.13,1ZM170.56,89,174,88.5l.13,1-3.48.46-.13-1ZM172.27,98l3.39-.91.26,1-3.39.92-.26-1Zm12.51-60.94,2.79,2.15L187,40l-2.79-2.15.61-.8Zm119.67,70.59-3.24-1.35.38-.93,3.25,1.35-.39.93ZM222.37,12.22l.9,3.41-1,.26-.91-3.41,1-.26Zm44.87,3.28-1.35,3.26-.92-.39,1.35-3.26.92.39Zm-35.88-5,.46,3.5-1,.13-.46-3.5,1-.13Zm27.23,2-.91,3.41-1-.26.91-3.41,1,.26ZM172.53,61.6l3.39.92-.26,1-3.39-.92.26-1Zm11.65,61.1,2.79-2.15.61.8-2.79,2.15-.61-.8ZM283,24.79l-2.14,2.8-.79-.61,2.14-2.8.79.61ZM175.53,52.91l3.25,1.35-.39.93-3.24-1.35.38-.93Zm74.1-42.29-.46,3.5-1-.13.46-3.5,1,.13Zm58.09,51.94-3.4.92-.25-1,3.39-.92.26,1ZM307.46,99l-3.39-.92.25-1,3.4.91-.26,1Zm-18.33,31.42-2.48-2.5.71-.71,2.48,2.5-.71.71ZM309.44,71.6l-3.48.46-.13-1,3.48-.46.13,1Zm-138.75-1,3.48.47-.13,1-3.48-.46.13-1Zm124.53,52.92-2.79-2.15.61-.8,2.79,2.15-.61.8ZM197.78,24.18,199.92,27l-.79.6L197,24.79l.79-.61Zm15.89-9.07L215,18.38l-.92.38-1.35-3.26.92-.39Zm-38.52,91.64,3.25-1.35.38.93-3.25,1.35-.38-.93ZM295.82,37.87,293,40l-.61-.79,2.79-2.15.61.8Zm9,16-3.25,1.35-.38-.92,3.25-1.36.38.93Zm-114-23.63,2.48,2.5-.71.71-2.48-2.5.71-.71Zm99,.71-2.48,2.49-.71-.71,2.48-2.49.71.71Zm-99.67,98.75,2.48-2.5.71.71-2.49,2.5Z" fill="#999"/>
    <g class="saturation dial" >
      <path d="M240,140.05a60.49,60.49,0,1,0-60.48-60.48A60.6,60.6,0,0,0,240,140.05Z" fill="#4d4d4d" fill-rule="evenodd"/>
      <path d="M240,24.07a55.42,55.42,0,0,1,46.08,24.57H193.91A55.45,55.45,0,0,1,240,24.07Z" fill="#ccc" fill-rule="evenodd"/>
      <path d="M285.48,47.76c.2.29.41.58.6.88H193.91c.2-.3.41-.59.61-.88Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <path d="M240,24.07a55.5,55.5,0,1,1-55.5,55.5A55.5,55.5,0,0,1,240,24.07Zm0,.73a54.77,54.77,0,1,0,54.77,54.77A54.77,54.77,0,0,0,240,24.8Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <circle cx="240" cy="29.49" r="2.15" fill="#333"/>
<text transform="translate(240 86)">SATURATION</text>
    </g>
  </g>
  <g id="LightnessDial">
    <path data-name="notches" d="M410.83,10V17h-1.66V10h1.66Zm34.89,9.84-3.52,6.12-1.43-.83L444.28,19l1.44.83ZM471,45.85,465,49.38l-.83-1.44,6.09-3.53.83,1.44Zm9,35.29h-7V79.47h7v1.67Zm-9.79,35.07-6.09-3.53.83-1.45,6.08,3.53-.82,1.45ZM349,114.76l6.09-3.53.83,1.45-6.09,3.53-.83-1.45Zm-9-35.29h7v1.67h-7V79.47Zm9.79-35.06,6.09,3.53-.83,1.44L349,45.85l.83-1.44ZM375.72,19l3.51,6.11-1.43.84-3.52-6.12.29-.17h0l.35-.2.8-.46ZM479.31,90l-3.48-.46.13-1,3.48.46-.13,1ZM340.56,89,344,88.5l.13,1-3.48.46-.13-1ZM342.27,98l3.39-.91.26,1-3.39.92-.26-1Zm12.51-60.94,2.79,2.15L357,40l-2.79-2.15.61-.8Zm119.67,70.59-3.24-1.35.38-.93,3.25,1.35-.39.93ZM392.37,12.22l.9,3.41-1,.26-.91-3.41,1-.26Zm44.87,3.28-1.35,3.26-.92-.39,1.35-3.26.92.39Zm-35.88-5,.46,3.5-1,.13-.46-3.5,1-.13Zm27.23,2-.91,3.41-1-.26.91-3.41,1,.26ZM342.53,61.6l3.39.92-.26,1-3.39-.92.26-1Zm11.65,61.1,2.79-2.15.61.8-2.79,2.15-.61-.8ZM453,24.79l-2.14,2.8-.79-.61,2.14-2.8.79.61ZM345.53,52.91l3.25,1.35-.39.93-3.24-1.35.38-.93Zm74.1-42.29-.46,3.5-1-.13.46-3.5,1,.13Zm58.09,51.94-3.4.92-.25-1,3.39-.92.26,1ZM477.46,99l-3.39-.92.25-1,3.4.91-.26,1Zm-18.33,31.42-2.48-2.5.71-.71,2.48,2.5-.71.71ZM479.44,71.6l-3.48.46-.13-1,3.48-.46.13,1Zm-138.75-1,3.48.47-.13,1-3.48-.46.13-1Zm124.53,52.92-2.79-2.15.61-.8,2.79,2.15-.61.8ZM367.78,24.18,369.92,27l-.79.6L367,24.79l.79-.61Zm15.89-9.07L385,18.38l-.92.38-1.35-3.26.92-.39Zm-38.52,91.64,3.25-1.35.38.93-3.25,1.35-.38-.93ZM465.82,37.87,463,40l-.61-.79,2.79-2.15.61.8Zm9,16-3.25,1.35-.38-.92,3.25-1.36.38.93Zm-114-23.63,2.48,2.5-.71.71-2.48-2.5.71-.71Zm99,.71-2.48,2.49-.71-.71,2.48-2.49.71.71Zm-99.67,98.75,2.48-2.5.71.71-2.49,2.5Z" fill="#999"/>
    <g class="lightness dial">
      <path d="M410,140.05a60.49,60.49,0,1,0-60.48-60.48A60.6,60.6,0,0,0,410,140.05Z" fill="#4d4d4d" fill-rule="evenodd"/>
      <path d="M410,24.07a55.42,55.42,0,0,1,46.08,24.57H363.91A55.45,55.45,0,0,1,410,24.07Z" fill="#ccc" fill-rule="evenodd"/>
      <path d="M455.48,47.76c.2.29.41.58.6.88H363.91c.2-.3.41-.59.61-.88Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <path d="M410,24.07a55.5,55.5,0,1,1-55.5,55.5A55.5,55.5,0,0,1,410,24.07Zm0,.73a54.77,54.77,0,1,0,54.77,54.77A54.77,54.77,0,0,0,410,24.8Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <circle cx="410" cy="29.49" r="2.15" fill="#333"/>
<text transform="translate(410 86)">LIGHTNESS</text>
    </g>
  </g>
  <g id="AlphaDial">
    <path d="M580.83,10V17h-1.66V10h1.66Zm34.89,9.84-3.52,6.12-1.43-.83L614.28,19l1.44.83ZM641,45.85,635,49.38l-.83-1.44,6.09-3.53.83,1.44Zm9,35.29h-7V79.47h7v1.67Zm-9.79,35.07-6.09-3.53.83-1.45,6.08,3.53-.82,1.45ZM519,114.76l6.09-3.53.83,1.45-6.09,3.53-.83-1.45Zm-9-35.29h7v1.67h-7V79.47Zm9.79-35.06,6.09,3.53-.83,1.44L519,45.85l.83-1.44ZM545.72,19l3.51,6.11-1.43.84-3.52-6.12.29-.17h0l.35-.2.8-.46ZM649.31,90l-3.48-.46.13-1,3.48.46-.13,1ZM510.56,89,514,88.5l.13,1-3.48.46-.13-1ZM512.27,98l3.39-.91.26,1-3.39.92-.26-1Zm12.51-60.94,2.79,2.15L527,40l-2.79-2.15.61-.8Zm119.67,70.59-3.24-1.35.38-.93,3.25,1.35-.39.93ZM562.37,12.22l.9,3.41-1,.26-.91-3.41,1-.26Zm44.87,3.28-1.35,3.26-.92-.39,1.35-3.26.92.39Zm-35.88-5,.46,3.5-1,.13-.46-3.5,1-.13Zm27.23,2-.91,3.41-1-.26.91-3.41,1,.26ZM512.53,61.6l3.39.92-.26,1-3.39-.92.26-1Zm11.65,61.1,2.79-2.15.61.8-2.79,2.15-.61-.8ZM623,24.79l-2.14,2.8-.79-.61,2.14-2.8.79.61ZM515.53,52.91l3.25,1.35-.39.93-3.24-1.35.38-.93Zm74.1-42.29-.46,3.5-1-.13.46-3.5,1,.13Zm58.09,51.94-3.4.92-.25-1,3.39-.92.26,1ZM647.46,99l-3.39-.92.25-1,3.4.91-.26,1Zm-18.33,31.42-2.48-2.5.71-.71,2.48,2.5-.71.71ZM649.44,71.6l-3.48.46-.13-1,3.48-.46.13,1Zm-138.75-1,3.48.47-.13,1-3.48-.46.13-1Zm124.53,52.92-2.79-2.15.61-.8,2.79,2.15-.61.8ZM537.78,24.18,539.92,27l-.79.6L537,24.79l.79-.61Zm15.89-9.07L555,18.38l-.92.38-1.35-3.26.92-.39Zm-38.52,91.64,3.25-1.35.38.93-3.25,1.35-.38-.93ZM635.82,37.87,633,40l-.61-.79,2.79-2.15.61.8Zm9,16-3.25,1.35-.38-.92,3.25-1.36.38.93Zm-114-23.63,2.48,2.5-.71.71-2.48-2.5.71-.71Zm99,.71-2.48,2.49-.71-.71,2.48-2.49.71.71Zm-99.67,98.75,2.48-2.5.71.71-2.49,2.5Z" fill="#999"/>
    <g class="alpha dial">
      <path d="M580,140.05a60.49,60.49,0,1,0-60.48-60.48A60.6,60.6,0,0,0,580,140.05Z" fill="#4d4d4d" fill-rule="evenodd"/>
      <path d="M580,24.07a55.42,55.42,0,0,1,46.08,24.57H533.91A55.45,55.45,0,0,1,580,24.07Z" fill="#ccc" fill-rule="evenodd"/>
      <path d="M625.48,47.76c.2.29.41.58.6.88H533.91c.2-.3.41-.59.61-.88Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <path d="M580,24.07a55.5,55.5,0,1,1-55.5,55.5A55.5,55.5,0,0,1,580,24.07Zm0,.73a54.77,54.77,0,1,0,54.77,54.77A54.77,54.77,0,0,0,580,24.8Z" fill="#e6e6e6" fill-rule="evenodd"/>
      <circle cx="580" cy="29.49" r="2.15" fill="#333"/>
<text transform="translate(580 86)">ALPHA</text>
    </g>
  </g>
</svg>
    <div id="colorData">
    <p id="hslaData">hsla(180, 50%, 50%, 1)</p>
  </div>
  </div>


              
            
!

CSS

              
                html {
  font-size: 20px;
}
body {
  font-family: "proxima-nova", sans-serif;
  overflow: hidden;
  background-image: linear-gradient(45deg, #808080 25%, transparent 25%),
    linear-gradient(-45deg, #808080 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #808080 75%),
    linear-gradient(-45deg, transparent 75%, #808080 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#colorContainer {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: hsla(180, 50%, 50%, 1);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
}

svg {
  width: 90vw;
  max-width: 960px;
  height: auto;
  overflow: visible;
}

text {
  font-size: 14px;
  text-anchor: middle;
  fill: #f2f2f2;
  font-weight: 700;
}

.base {
  fill: rgb(20, 20, 40);
}

p {
  font-size: 1rem;
  font-weight: 600;
  padding: 0;
  margin: 0;
  line-height: 1;
  color: white;
}

h1 {
  color: white;
  text-shadow: rgba(0, 0, 0, 0.4) 3px 3px 3px;
  font-size: 2.6rem;
}

#colorData {
  margin-top: 2rem;
  background: rgb(20, 20, 40);
  width: 280px;
  text-align: center;
  padding: 1rem;
  border-radius: 400px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
  border: solid 2px white;
}

a {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgb(20, 20, 40);
  color: white;
  font-weight: 500;
  padding: 10px 1rem;
  z-index: 5;
  border-radius: 100px;
  font-size: 0.75rem;
}


              
            
!

JS

              
                gsap.registerPlugin(Draggable);
const color = { hue: 180, saturation: 50, lightness: 50, alpha: 1 }; // initial HSLA color
const colorContainer = document.querySelector("#colorContainer");
const hslaData = document.querySelector("#hslaData");
const updateColor = () =>
  (hslaData.innerText = colorContainer.style.backgroundColor = `hsla(${color.hue}, ${color.saturation}%, ${color.lightness}%, ${color.alpha})`);

createDial("hue", 360);
createDial("saturation", 100);
createDial("lightness", 100);
createDial("alpha", 1);

function createDial(name, max) {
  const bounds = { minRotation: -135, maxRotation: 135 },
    map = gsap.utils.pipe(
      gsap.utils.mapRange(bounds.minRotation, bounds.maxRotation, 0, max), // map the rotation to the value range
      gsap.utils.snap(max > 1 ? 1 : 0.01) // round appropriately
    );
  gsap.set("." + name, {
    // we use a className in the markup, like ".hue", ".saturation", etc.
    transformOrigin: "center center",
    rotation: gsap.utils.mapRange(
      0,
      max,
      bounds.minRotation,
      bounds.maxRotation,
      color[name]
    )
  });
  Draggable.create("." + name, {
    type: "rotation",
    bounds: bounds,
    onDrag() {
      color[name] = map(this.rotation);
      updateColor();
    }
  });
}

              
            
!
999px

Console