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

              
                <custom-button>Button Text</custom-button>
              
            
!

CSS

              
                custom-button {
  border: 2px dotted red;
  padding: 1em 2em;
}
              
            
!

JS

              
                const template = document.createElement("template");
template.innerHTML = /*html*/`
  <button><slot></slot></button>
`;

const sheet = new CSSStyleSheet();
sheet.replaceSync(/*css*/`
/* Defaults */
:host {
	display: contents;
	/* Style the "button" here, especially in ways that a consumer could _override_. */
  /* For instance... */
	border-radius: calc(Infinity * 1px);
	align-items: center;
	line-height: 1.5;
	border: 2px solid;
	font-weight: 500;
	cursor: pointer;
	width: max-content;
  padding: 5px 10px;
}
/* Pass all styles from :host to button */
button {
  all: inherit;
  display: inline-flex;
  box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
	/* Because accessibility means so much more than just Tab keys and screen readers! */
	:host {
		transition:
			outline 0.3s ease-in-out,
			outline-offset 0.3s ease-in-out;
	}
}
/* Required */
/*
 * All of our elements need _something_ to be a specific way, like accessibility.
 * This prevents the consumer from futzing with those things.
 **/
button:not(:focus-visible) {
	outline: 2px solid transparent;
	outline-offset: 0px;
}
button:focus-visible {
	outline: 2px solid royalblue;
	outline-offset: 2px;
}
/* Overrides */
:host([disabled]) {
	background: var(--background-tertiary);
	color: var(--content-disabled);
	pointer-events: none;
}
`);

class CustomButton extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
    this.shadowRoot.appendChild(template.content.cloneNode(true));
    this.shadowRoot.adoptedStyleSheets = [sheet];
  }
}

customElements.define("custom-button", CustomButton);
              
            
!
999px

Console