Pen Settings



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


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


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.


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.


                <div class="flex flex-col items-center">
  <div class="flex items-center mb-4">
    <input id="input" class="rounded-md w-24 h-6 border border-neutral-700 text-center" type="text" value="#894ed7">
  <div id="card" class="rounded-lg border-4 border-neutral-100 shadow-xl flex flex-col  gap-y-4 bg-white shadow-xl w-64 h-64 flex items-center justify-center" style="background:#db7cff">
    <div class="flex items-center">
      <div id="output" class="rounded-md w-24 h-6 border bg-white border-neutral-700 text-center">#db7cff</div>

<a class="text-white absolute bottom-4 right-4 bg-indigo-400 bg-opacity-20  rounded-full py-1 px-3" href="" target="_blank"></a>


                body {
  background: #894ed7;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 0;
  margin: 0;


                function darkenColor(color, percent) {
  // Strip the leading # if it's there
  color = color.replace(/^\s*#|\s*$/g, "");

  // Convert 3 char codes -> 6, e.g. `E0F` -> `EE00FF`
  if (color.length == 3) {
    color = color.replace(/(.)/g, "$1$1");

  // Split HEX Color
  const hexR = color.substring(0, 2);
  const hexG = color.substring(2, 4);
  const hexB = color.substring(4, 6);

  // HEX to RGB
  let r = parseInt(hexR, 16);
  let g = parseInt(hexG, 16);
  let b = parseInt(hexB, 16);

  if (isNaN(r)) r = 0;
  if (isNaN(g)) g = 0;
  if (isNaN(b)) b = 0;

  // Manipulate
  const newR = Math.min(255, Math.floor(r + (r * percent) / 100));
  const newG = Math.min(255, Math.floor(g + (g * percent) / 100));
  const newB = Math.min(255, Math.floor(b + (b * percent) / 100));

  // RGB to HEX
  const newHexRColor = `${newR.toString(16)}`.padStart(2, "0");
  const newHexGColor = `${newG.toString(16)}`.padStart(2, "0");
  const newHexBColor = `${newB.toString(16)}`.padStart(2, "0");

  return "#" + newHexRColor + newHexGColor + newHexBColor;

// Demo
$("#input").keyup((event) => {
  $("body").attr("style", "background:" +;

  const percent = 60; // Min: -100 / Max: 100
  const newColor = darkenColor(, percent);

  $("#card").attr("style", "background:" + newColor);