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.


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.


    <button id="set-focus">Set and Trap Focus</button>
    <button id="remove-focus">Remove Focus</button>

<div id="focus-region">
    <h1 tabindex="0">Focus Trap Region</h1>
    <p>Once this region receives focus, you can no longer tab out of it; instead, the focus loops through focussable child elements.</p>
    <p>You can press `esc` to remove focus from this region, once it's been set.</p>
        The `Set and Trap Focus` button is focused on page load to demonstrate that when focus is removed from the region, it returns to the last focussed element.</p>
    <p>Aria-roles are omitted to concentrate on the focus management functionality, but are equally crucial for better accessibility.</p>
    <button id="close">Close</button>


                #focus-region {
    border: 1px solid #ccc;
    padding: 1rem;
    margin: 1rem;


The `focusing` module comes from 'Settings -> Javascript: Add External Javascript'

var focusRegion = document.getElementById('focus-region'),

function handleKeypress(e) {
    focusing.bindKeypress(true, function() {
    }, focusRegion, e);

function handleMaintainFocus(e) {
    focusing.maintainFocus(true, focusRegion, e);

function handleSetFocus(e) {
    previousFocusedElement = focusing.safeActiveElement();
    document.addEventListener('keydown', handleKeypress);
    document.body.addEventListener('focus', handleMaintainFocus, true);

function handleRemoveFocus(e) {
    document.removeEventListener('keydown', handleKeypress);
    document.body.removeEventListener('focus', handleMaintainFocus, true);
    previousFocusedElement && previousFocusedElement.focus();


document.getElementById('set-focus').addEventListener('click', handleSetFocus);
document.getElementById('remove-focus').addEventListener('click', handleRemoveFocus);
document.getElementById('close').addEventListener('click', handleRemoveFocus);