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

              
                <main id=app>
  <h1>Aqua Buttons</h1>

  <div class="static">
    <button>
      <span>
        Aqua button
      </span>
      <svg viewBox="0 0 22 22" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
        <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
        <line x1="5" y1="12" x2="19" y2="12"></line>
        <line x1="15" y1="16" x2="19" y2="12"></line>
        <line x1="15" y1="8" x2="19" y2="12"></line>
      </svg>

      <svg class="spinner" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
        <path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z" />
      </svg>

    </button>
    <input id="size" type="range" min=0.5 max=3.5 value=2 step=0.1 title="Size">
    <input id="blur" type="range" min=0 max=3 value=0 step=0.1 title="Frosted Glass Magnitude">
  </div>

  <div class="custom">
    <button>
      <span>
        Randomize
      </span>
      <svg viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
        <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
        <path d="M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"></path>
        <circle cx="8.5" cy="10.5" r="1"></circle>
        <circle cx="12.5" cy="7.5" r="1"></circle>
        <circle cx="16.5" cy="10.5" r="1"></circle>
      </svg>

    </button>

    <input id="hue1" type="range" min=0 max=360 value=30 title="Background Hue">
    <input id="sat1" type="range" min=0 max=100 value=50 title="Background Saturation">
    <input id="hue2" type="range" min=0 max=360 value=5 title="Foreground Hue">
    <input id="sat2" type="range" min=0 max=100 value=80 title="Foreground Saturation">
    <input id="gradoff" type="range" orient="vertical" min="20" max="120" value=50 title="Transition Position">
    <input id="grad" type="range" orient="vertical" min="10" max="40" value=30 title="Transition Size">
  </div>
  
  
  <button class="single">
    single element
  </button>
  
  <p>design inspiration from <a href="https://twitter.com/alazybrick/status/1600191967907938320">@alazybrick on Twitter</a></p>
</main>
              
            
!

CSS

              
                :root {
  --hue: 190deg;
  --sat: 50%;
  --blur: 0em;
  
  
  --hue2: calc(var(--hue) + 60deg);
  --sat2: calc(var(--sat) + 10%);
  --clr: hsl(var(--hue) var(--sat) 90%);  
  --clr2: hsl(var(--hue2) var(--sat2) 85%);
  --text: hsla(var(--hue), 70%, 10%, .9);
  --gradoffset: 45%;
  --gradgap: 30%;
}

#app div {
  --hue2: calc(var(--hue) + 60deg);
  --sat2: calc(var(--sat) + 10%);
  --clr: hsl(var(--hue) var(--sat) 90%);  
  --clr2: hsl(var(--hue2) var(--sat2) 85%);
  --text: hsla(var(--hue), 70%, 10%, .9);
  --gradoffset: 45%;
  --gradgap: 30%;
}

#app .custom {
  --hue: 30deg;
  --sat: 50%;
  --hue2: 5deg;
  --sat2: 80%;
}

button {
  
  font-size: calc(var(--size,2vw) * 2 );
  @media screen and ( min-width: 660px ) {
    font-size: var(--size,2vw);
  }
  
  color: var(--text);
  font-weight: 500;
  letter-spacing: -0.025em;
  background-color: var(--clr);
  background-image:   
    linear-gradient(180deg, 
      var(--clr2) var(--gradgap), 
      transparent calc(100% - var(--gradgap))
    );
  background-repeat: no-repeat;
  background-position: center var(--gradoffset);
  background-size: 100% 200%;
  padding: 1.1em 1.5em;
  border-radius: 2em;
  border: none;
  overflow: hidden;
  justify-content: center;
  margin: auto;
  
  box-shadow: 
    0 -0.5em 0.5em transparent,
    0 0.5em 0.5em transparent,
    0 0.25em 0.3em -0.2em hsla(var(--hue), var(--sat), 50%, 0.46), 
    0 0.25em 0.75em hsla(var(--hue), calc(var(--sat) - 10%), 40%, 0.3);

  position: relative;
  transition: all 0.5s linear(0, 0.176 4.5%, 0.331 9%, 0.47 13.6%, 0.595 18.4%, 0.704 23.3%, 0.752 25.8%, 0.795 28.3%, 0.836 30.9%, 0.872 33.5%, 0.905 36.1%, 0.934 38.8%, 0.957 41.3%, 0.977 43.8%, 0.995 46.4%, 1.009 49%, 1.021 51.7%, 1.031 54.5%, 1.038 57.3%, 1.042 60.3%, 1.045 65.2%, 1.041 70.6%, 1.034 76.1%, 1.007 91.2%, 1.002 95.8%, 1);
  outline: none;

  &::before, &::after {
    content: "";
    inset: 0;
    position: absolute;
    border-radius: 5em;
  }
  
  // darkening
  &::before {
    background-image: 
      radial-gradient(ellipse, 
        hsla(var(--hue), 100%, 90%, .8) 20%,
        transparent 50%,
        transparent 200%
      ),
      linear-gradient(90deg, 
        hsl(0deg, 0%, 25%) -10%, 
        transparent 30%, 
        transparent 70%, 
        hsl(0deg, 0%, 25%) 110%
      );
    box-shadow: 
      inset 0 .25em .75em hsla(0deg, 0%, 0%, 0.8),
      inset 0 -.05em .2em rgba(255, 255, 255, 0.4),
      inset 0 -1px 3px hsla(var(--hue), 80%, 50%, .75);
    background-blend-mode: overlay;
    background-repeat: no-repeat;
    background-size: 200% 80%, cover;
    background-position: center 220%;
    mix-blend-mode: overlay;
    filter: blur(calc(var(--blur) / 32));
  }
  
  // reflection
  &::after {
    background: linear-gradient(
      180deg, 
      hsla(var(--hue2),100%,90%,.9), 
      hsla(var(--hue2),calc(var(--sat2)*0.7),50%,.75) 40%, 
      transparent 80%
    );
    top: 0.075em;
    left: 0.75em;
    right: 0.75em;
    bottom: 1.4em;
    filter: blur(calc(var(--blur) / 16));
    mix-blend-mode: screen;
  }
  
  &:hover,
  &:active,
  &:focus {
    outline: none;
    box-shadow: 
      0 -0.2em 0.5em hsla(var(--hue2), 70%, 80%, 0.3), 
      0 0.25em 0.5em hsla(var(--hue), 70%, 80%, 0.25), 
      0 0.25em 0.3em -0.2em hsl(var(--hue), 90%, 70%), 
      0 0.25em 0.5em hsla(var(--hue), 20%, 30%, 0.2), 
      inset 0 -2px 2px rgba(255, 255, 255, 0.2);
    background-position: center calc( var(--gradoffset) - 0.75em );
  }
  
  &:active {
    scale: 0.95;
    transition: all 0.25s linear(0, 0.028 5.2%, 0.056 9.8%, 0.085 13.8%, 0.116 17.4%, 0.149 20.7%, 0.187 23.9%, 0.229 26.9%, 0.278 29.9%, 0.328 32.6%, 0.383 35.3%, 0.445 38%, 0.513 40.7%, 0.636 45.2%, 0.898 54.1%, 0.999 57.7%, 0.89 62.3%, 0.85 64.3%, 0.819 66.2%, 0.795 68.1%, 0.778 69.9%, 0.768 71.7%, 0.765 73.6%, 0.767 75.1%, 0.774 76.6%, 0.785 78.2%, 0.8 79.8%, 0.837 82.8%, 0.934 89.6%, 0.956 91.4%, 0.973 93.1%, 0.986 94.8%, 0.994 96.4%, 0.999 98.1%, 1);
  }
  
}



.static button {
  position: relative;
}
.static button .spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateY(.75em) translateX(-50%);
  opacity: 0;
  margin: 0;
  font-size: 2em;
  mix-blend-mode: overlay;
}
.static button span,
.static button svg,
.static button .spinner {
  transition: all 0.33s ease;
}

.static button:active,
.static button:focus {
  span,
  svg:not(.spinner) {
    transform: translateY(-1em);
    opacity: 0;
    filter: blur(5px);
  }
  .spinner {
    transform: translateY(-0.5em) translateX(-50%);
    opacity: 1;
  }
}










// app styles

body {
  --font: "Noto Sans", sans-serif;
  color: white;
  background: #3b3d4c;
  font-family: var(--font);
  font-weight: 200;
  padding: 1vw;
  text-align: center;
}

button {
  font-family: var(--font);
  display: flex;
}

svg {
  height: 1em;
  width: auto;
  margin-left: .33em;
}

button svg,
button span {
  display: inline-flex;
  align-content: center;
  align-self: center;
  filter: drop-shadow(0 1px 0 hsla(var(--hue), 90%, 88%, 1));
}

#app {
  display: grid;
  gap: 2vw;
  @media screen and (min-width: 660px) {
    grid-template-columns: auto auto;
    grid-template-rows: min-content 2fr 1fr min-content;
  }
}

h1, p, button {
  grid-column: 1/-1;
}

h1 { margin: 0.5em 0 0; }


#app > div {
  position: relative;
  border-radius: 2vw;
  min-height: 200px;
  background-color: hsl(var(--hue), 20%, 95%);
  background-image: 
    linear-gradient( 33deg, 
      transparent 60%, 
      var(--clr) 
    ),
    linear-gradient( 210deg, 
      transparent 60%, 
      var(--clr2) 
    );
  background-size: 150%;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: rgba(0, 0, 0, 0.15) 0px 15px 25px, rgba(0, 0, 0, 0.05) 0px 5px 10px;
}

body, html, #app {
  height: 100%;
  box-sizing: border-box;
}

a {
  color: #6adcf6;
}

input[type=range] {
  position: absolute;
  top: .5em;
  left: .5em;
  right: .5em;
  width: 40%;
}

#hue1 {
  top: auto;
  bottom: .5em;
}

#sat1 {
  top: auto;
  bottom: .5em;
  left: auto;
}

#hue2 {
}

#sat2 {
  left: auto;
}

#grad {
  left: auto;
  top: 50%;
  transform: translateY(-50%);
}
#gradoff {
  top: 50%;
  transform: translateY(-50%);
}

#blur {
  top: auto;
  bottom: .5em;
  left: 50%;
  transform: translateX(-50%);
}

#size {
  top: .5em;
  left: 50%;
  transform: translateX(-50%);
}












input {
  font-family: inherit;
  color: white;
  background: #3b3d4c;
  padding: 0.875em;
  border-radius: 8px;
  border: 1px solid transparent;
  outline: 1px solid transparent;
  accent-color: var(--clr);
  box-shadow: 0 3px 2px -3px var(--clr);
  transition: border 0.3s ease-in, outline 0.6s ease-in, box-shadow 0.6s ease-in;

  &:focus {
    border-color: var(--clr2);
    outline-color: var(--clr2);
    transition: border 0.6s ease-out, outline 0.3s ease-out,
      box-shadow 0.3s ease-out;
  }

  &::placeholder {
    opacity: 0.33;
    font-style: italic;
  }
}

input[type="range"] {
  appearance: none;
  height: calc(1em + 2px * 2);
  background: #3b3d4c;
  border: none;
  outline: none;
  padding: 5px;
  border-radius: 1em;

  &,
  &* {
    transition: all 0.5s ease;
  }
}

@mixin range-thumb {
  appearance: none;
  width: 1em;
  height: 1em;
  border: none;
  outline: none;
  background: #eee;
  border-radius: 1em;
  transform: translate3d(0, 0, 0);
}

@mixin range-track {
  background: #3b3d4c;
  display: block;
  width: calc(100% + 5px * 2);
  height: calc(1em + 5px * 2);
  border-radius: 1em;
  margin-inline: calc(5px * -1);
  transition: opacity 0.5s ease-in, background 0.5s ease-in;
  opacity: 0;
  will-change: opacity, background;
}

input[type="range"]::-webkit-slider-runnable-track {
  @include range-track;
  background: #3b3d4c;
  padding: 0.25em 5px;
  opacity: 1;
}
input[type="range"]::-moz-range-track {
  @include range-track;
}
input[type="range"]::-ms-track {
  @include range-track;
}

input[type="range"]::-webkit-slider-thumb {
  @include range-thumb;
}
input[type="range"]::-moz-range-thumb {
  @include range-thumb;
}
input[type="range"]::-ms-thumb {
  @include range-thumb;
}

input[type="range"][orient="vertical"]{
  writing-mode: bt-lr;
  height: 120px;
  width: calc(1em + 2px * 2);
  appearance: slider-vertical;
}



.spinner path {
  transform-origin: center;
  animation: spin .75s infinite linear
}

@keyframes spin {
  100% {
    transform: rotate(360deg)
  }
}
              
            
!

JS

              
                let randomise = () => {
  
  $("#hue1").val( Math.floor(Math.random() * 360) );
  $("#sat1").val( Math.floor(Math.random() * 360) );
  $("#hue2").val( Math.floor(Math.random() * 70) + 15 );
  $("#sat2").val( Math.floor(Math.random() * 70) + 15 );
  $("#grad").val( Math.floor(Math.random() * 10) + 20 );
  $("#gradoff").val( Math.floor(Math.random() * 20) + 40 );
  
  $(".custom").css({
    "--hue":  $("#hue1").val() + "deg",
    "--sat":  $("#sat1").val() + "%",
    "--hue2": $("#hue2").val() + "deg",
    "--sat2": $("#sat2").val() + "%",
    "--gradgap": $("#grad").val() + "%",
    "--gradoffset": $("#gradoff").val() + "%"
  });
}

setTimeout( () => {
  $("input[type=range]").on("input", (e) => {
    $(".custom").css({
      "--hue":  $("#hue1").val() + "deg",
      "--sat":  $("#sat1").val() + "%",
      "--hue2": $("#hue2").val() + "deg",
      "--sat2": $("#sat2").val() + "%",
      "--gradgap": $("#grad").val() + "%",
      "--gradoffset": $("#gradoff").val() + "%"
    });
    $("#app").css({
      "--blur": $("#blur").val() + "em",
      "--size": $("#size").val() + "vw"
    });
  });
}, 1000 );

$(".custom button").on("click", randomise);














function HexToHSL(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);

    var r = parseInt(result[1], 16);
    var g = parseInt(result[2], 16);
    var b = parseInt(result[3], 16);

    r /= 255, g /= 255, b /= 255;
    var max = Math.max(r, g, b), min = Math.min(r, g, b);
    var h, s, l = (max + min) / 2;

    if(max == min){
        h = s = 0; // achromatic
    } else {
        var d = max - min;
        s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
        switch(max) {
            case r: h = (g - b) / d + (g < b ? 6 : 0); break;
            case g: h = (b - r) / d + 2; break;
            case b: h = (r - g) / d + 4; break;
        }
        
        h /= 6;
    }

    s = s*100;
    s = Math.round(s);
    l = l*100;
    l = Math.round(l);
    h = Math.round(360*h);

    return {h, s, l};
}
              
            
!
999px

Console