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

              
                <p>
  <strong>Note</strong>: This only works a little bit and not at all in Firefox. I'm in the process of completing this and moving it to its own site. See <a href="https://tylergaw.com/blog/css-typed-om-thread/">my post</a> about it for background.
</p>
<form>
  <label>Plop a CSS Function here</label>
  <input type="text" id="value" required value="cos(25deg)"> and
  <button type="submit">Get the result</button>
</form>

<div>
  <p>Result:</p>
  <p id="output"></p>
</div>
              
            
!

CSS

              
                

              
            
!

JS

              
                const form = document.querySelector("form");
const output = document.querySelector("#output");

function getParsedValue(input) {
  const original = CSSStyleValue.parse("--o", input);
  console.log(original);
  let parsed;
  let value;
  let unit = null;

  try {
    parsed = CSSNumericValue.parse(original);
    unit = parsed.values[0].unit;
  } catch (err) {
    console.log("Couldn't parse CSSNumericValue, converting it");
    const t = CSSStyleValue.parse("--t", `calc(${original[0]} * 1px`);
    parsed = CSSNumericValue.parse(t);
  }

  return {
    raw: parsed,
    unit,
    value: parsed.values[0].value
  };
}

form.addEventListener(
  "submit",
  (e) => {
    e.preventDefault();
    const input = form.querySelector("#value").value;
    const { raw, value, unit } = getParsedValue(input);
    output.textContent = `${value}${unit || ""}`;
  },
  false
);

              
            
!
999px

Console