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

              
                <fieldset id="wrap" style="view-transition-name: wrap">
  <legend>Flex Wrap</legend>
  
  <label>
    Wrap
    <input type="radio" name="wrap-controls" value="wrap" checked>
  </label>
  
  <label>
    No Wrap
    <input type="radio" name="wrap-controls" value="nowrap">
  </label>
</fieldset>

<fieldset id="direction" style="view-transition-name: direction">
  <legend>Flex Direction</legend>
  
  <label>
    Row
    <input type="radio" name="direction-controls" value="row" checked>
  </label>
  
  <label>
    Row Reverse
    <input type="radio" name="direction-controls" value="row-reverse">
  </label>
  
  <label>
    Column
    <input type="radio" name="direction-controls" value="column">
  </label>
  
  <label>
    Column Reverse
    <input type="radio" name="direction-controls" value="column-reverse">
  </label>
</fieldset>

<fieldset id="alignItems" style="view-transition-name: align-items">
  <legend>Align Items</legend>
  
  <label>
    Start
    <input type="radio" name="align-items-controls" value="start" checked>
  </label>
  
  <label>
    Center
    <input type="radio" name="align-items-controls" value="center">
  </label>
  
  <label>
    End
    <input type="radio" name="align-items-controls" value="end">
  </label>
  
  <label>
    Stretch
    <input type="radio" name="align-items-controls" value="stretch">
  </label>
</fieldset>

<fieldset id="alignContent" style="view-transition-name: align-content">
  <legend>Align Content</legend>
  
  <label>
    Start
    <input type="radio" name="align-content-controls" value="start" checked>
  </label>
  
  <label>
    Center
    <input type="radio" name="align-content-controls" value="center">
  </label>
  
  <label>
    End
    <input type="radio" name="align-content-controls" value="end">
  </label>
  
  <label>
    Space Between
    <input type="radio" name="align-content-controls" value="space-between">
  </label>
  
  <label>
    Space Around
    <input type="radio" name="align-content-controls" value="space-around">
  </label>
  
  <label>
    Space Evenly
    <input type="radio" name="align-content-controls" value="space-evenly">
  </label>
  
<!--   <label>
    Stretch
    <input type="radio" name="align-content-controls" value="stretch">
  </label> -->
</fieldset>

<fieldset id="justifyContent" style="view-transition-name: justify-content">
  <legend>Justify Content</legend>
  
  <label>
    Start
    <input type="radio" name="justify-content-controls" value="start" checked>
  </label>
  
  <label>
    Center
    <input type="radio" name="justify-content-controls" value="center">
  </label>
  
  <label>
    End
    <input type="radio" name="justify-content-controls" value="end">
  </label>
  
  <label>
    Space Between
    <input type="radio" name="justify-content-controls" value="space-between">
  </label>
  
  <label>
    Space Around
    <input type="radio" name="justify-content-controls" value="space-around">
  </label>
  
  <label>
    Space Evenly
    <input type="radio" name="justify-content-controls" value="space-evenly">
  </label>
  
  <label>
    Stretch
    <input type="radio" name="justify-content-controls" value="stretch">
  </label>
</fieldset>

<div class="flex" id="demo">
  <div class="item" style="view-transition-name: item-1">1</div>
  <div class="item" style="view-transition-name: item-2">2</div>
  <div class="item" style="view-transition-name: item-3">3</div>
  <div class="item" style="view-transition-name: item-4">4</div>
  <div class="item" style="view-transition-name: item-5">5</div>
  <div class="item" style="view-transition-name: item-6">6</div>
  <div class="item" style="view-transition-name: item-7">7</div>
</div>
              
            
!

CSS

              
                @layer demo {
  .flex {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: start;
    justify-content: start;
    
    border: 1px solid Highlight;
    padding: 1rem;
    
    inline-size: min(80vw, 1024px);
    block-size: 50vh;
    margin-block-start: 5vh;
  }
  
  .item {
    color: Canvas;
    background: CanvasText;
    inline-size: min(15vw, 175px);
    aspect-ratio: 4/3;
    
    &:nth-child(3) {
      aspect-ratio: 3/4;
    }
    
    &:nth-child(6) {
      aspect-ratio: 16/9;
    }
  }
}

@layer demo.support {
  * {
    box-sizing: border-box;
    margin: 0;
  }

  html {
    block-size: 100%;
    color-scheme: dark light;
  }

  body {
    min-block-size: 100%;
    font-family: system-ui, sans-serif;

    display: grid;
    place-content: center;
    gap: 1rem;
    padding: 1rem;
  }
  
  fieldset {
    max-inline-size: max-content;
    display: flex;
    flex-wrap: wrap;
    gap: 1ch 2ch;
    border-color: #8885;
    
    > label {
      display: flex;
      gap: 1ch;
      align-items: center;
      white-space: nowrap;
    }
  }
}
              
            
!

JS

              
                // make demo cross browser, just wont animate if they cant
function mutate(prop, val) {
  if (document.startViewTransition) {
    document.startViewTransition(() => {
      demo.style[prop] = val
    })
  }
  else {
    demo.style[prop] = val
  }
}

direction.oninput = e => {
  mutate('flexDirection', e.target.value)
}

wrap.oninput = e => {
  mutate('flexWrap', e.target.value)
}

justifyContent.oninput = e => {
  mutate('justifyContent', e.target.value)
}

alignItems.oninput = e => {
  mutate('alignItems', e.target.value)
}

alignContent.oninput = e => {
  mutate('alignContent', e.target.value)
}
              
            
!
999px

Console