Pen Settings



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


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.


    <h1>Fallback, "light DOM" content</h1>
    <p>This content will live in a slot element. We'll make paragraphs look different if web components are supported.</p>


                :root {
    --button-bg: #2c3e50;

body {
    padding: 2rem;
    font-family: sans-serif;
    line-height: 1.4;

h1 {
    line-height: 1.1;

first-component {
    display: block;
    max-width: 60ch;



                // First, create the class that defines our custom element
class FirstComponent extends HTMLElement {
    constructor() {
        this.buttonText = 'Oh hey, click me for a party';
        // Create and attach a shadow root
        this._shadowRoot = this.attachShadow({ mode: 'open' });
    render() {
        this._shadowRoot.innerHTML = `

                /* Button styles from "Button Pal" */
                button {
                    display: inline-block;
                    border: none;
                    padding: 1rem 2rem;
                    margin: 0;
                    text-decoration: none;
                    /* Custom props allow us to style from the outside too */
                    background: var(--button-bg, #0069ed);

                    color: #ffffff;
                    font-family: sans-serif;
                    font-size: 1rem;
                    cursor: pointer;
                    text-align: center;
                    transition: background 250ms ease-in-out, 
                                transform 150ms ease;
                    -webkit-appearance: none;
                    -moz-appearance: none;

                button:focus {
                    background: #0053ba;

                button:focus {
                    outline: 1px solid #fff;
                    outline-offset: -4px;

                button:active {
                    transform: scale(0.99);

                /* Make paragraphs italic, red and bigger */
                ::slotted(p) {
                    font-style: italic;
                    font-weight: 500;
                    color: #c0392b;
                    font-size: 1.2rem;
    bindEvents() {
        // We couldn't access this button via the `document` which is cool
        this._shadowRoot.querySelector('button').addEventListener('click', (evt) => {

customElements.define('first-component', FirstComponent);