Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

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.

HTML

              
                <body class="page page_theme_islands">
<script type="text/bemjson">
{
 "block": "hello",
 "content": [
    {
        "elem": "greeting",
        "content": "Hello, %user%!"
    },
    {
        "block" : "input",
        "mods" : { "theme" : "islands", "size" : "m" },
        "mix" : { "block" : "hello", "elem" : "input" },
        "name" : "name",
        "placeholder" : "User name"
    },
    {
        "block" : "button",
        "mods" : { "theme" : "islands", "size" : "m", "type" : "submit" },
        "text" : "Click"
    }
 ]
}
</script>
</body>
              
            
!

CSS

              
                @use rebem-css
:block(hello)
{
  color: green;
  padding: 10%;

  &__greeting
  {
    margin-bottom: 12px;
  }

  &__input
  {
    margin-right: 12px;
  }
}
              
            
!

JS

              
                /**
 * @module hello
 */
modules.define(
  'hello', // a block name
  ['i-bem__dom'], // dependence connection
  function(provide, BEMDOM) { // a function that received names of the used modules

    /**
     * @exports
     * @class hello
     * @bem
     */
    provide(BEMDOM.decl(this.name, /** @lends hello.prototype */ { // a block declaration
      onSetMod: { // a constructor that describes reaction on an event
        'js': {
          'inited': function() {
            this._input = this.findBlockInside('input');

            this.bindTo('submit', function(e) { // the event that causes reaction
              e.preventDefault(); // prevention of event triggering by default (form data sending to the server with page reload)
              this.elem('greeting').text('Hello, ' + this._input.getVal() + '!');
            });
          }
        }
      }
    }));
  }
);

/**
 * Template
 */
modules.define( 'BEMHTML', [], function ( provide, BEMHTML ) {
  BEMHTML.compile(function() {
    block('hello')(
      js()(true),
      tag()('form')
    );
  });
  provide( BEMHTML );
} );

/**
 * @module bemjson
 */
modules.define( 'bemjson', ['i-bem__dom', 'jquery', 'BEMHTML'],
  function ( provide, BEMDOM, $, BEMHTML ) {
    
    BEMDOM.decl( this.name, {
      onSetMod: {
        js: {
          inited: function () {
            BEMDOM.replace( this.domElem, BEMHTML.apply( JSON.parse( this.domElem.text() ) ) );
          }
        }
      }
    } );

    provide( BEMDOM );

    $( BEMDOM.doc ).ready( function () {
      $( '[type="text/bemjson"]' ).bem( 'bemjson' );
    } );
  }
);
              
            
!
999px

Console