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.


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.

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.


                <input type='text' id='resizer' placeholder='Fill me with text.'>


  Resizing text, text box

  A little experiment to improve the user experience of the text box by:

    1. Using a focusing shadow effect when the box is being used

    2. Shrinking the font size when the user fills the box... so you can get in those few extra characters.

  by Tim Holman - @twholman

  Details at:



  -  None of this is required for resizer to work.

body {
    background-image: url(;
    width: 100%;
    background-size: fit;

    color: #333;
    width: 280px;
    height: 38px;
    margin-left: -150px;
    margin-top: -19px;
    position: fixed;
    left: 50%;
    top: 50%;
    padding-left: 10px;
    padding-right: 10px;

    transition: box-shadow 320ms;

    box-shadow: 0px 0px 8px 10px rgba(0,0,0,0.1);
    border-radius: 3px;
    font-size: 18px;
    border: 0px;

input[type='text']:focus {

    outline: 0px;
    outline-offset: 0px;
    box-shadow: 0px 0px 1px 5px rgba(0,0,0,0.12);

input:-moz-placeholder {
    color: #cccccc;


                function Resizer( element ) {

    var inputBox = element;
    var cssRules = window.getComputedStyle(inputBox);
    var maxFontSize = parseInt(cssRules.getPropertyValue("font-size"));
    var minFontSize = 11; // 11 is pretty damn small!
    var currentFontSize = maxFontSize;
    var maxScrollWidth = parseInt(cssRules.getPropertyValue("width"))
    var fontFamily = cssRules.getPropertyValue("font-family");
    var currentText = inputBox.value;

    // Canvas used to check text widths.
    var canvas = document.createElement('canvas');
    var context = canvas.getContext('2d');

    var initialize = function() {

        inputBox.oninput = onUpdate;

    var onUpdate = function(event) {

        var width;
        // Some text has been deleted!
        if (inputBox.value.length < currentText.length) {
            width = checkTextWidth(inputBox.value, currentFontSize + 1);

            while (width < maxScrollWidth && currentFontSize < maxFontSize) {
                currentFontSize += 1;
       = currentFontSize + 'px';
                width = checkTextWidth(inputBox.value, currentFontSize + 1);

            currentText = inputBox.value;


        var width = checkTextWidth(inputBox.value, currentFontSize);

        // Shrink
        while (currentFontSize > minFontSize && width > maxScrollWidth) {
            currentFontSize -= 1;
   = currentFontSize + 'px';
            width = checkTextWidth(inputBox.value, currentFontSize);

        currentText = inputBox.value;

    var checkTextWidth = function(text, size) {
        context.font = size + "px " + fontFamily;

        if (context.fillText) {
            return context.measureText(text).width;
        } else if (context.mozDrawText) {
            return context.mozMeasureText(text);

    // Initialize the auto adapt functionality.

Resizer( document.getElementById( 'resizer' ) );