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.


                <main class="container">
  <h1>Rank Ice Cream Flavors</h1>
  <div x-data="{ items: ['Chocolate', 'Vanilla', 'Strawberry', 'Cookies and Creme'], newItem:'', dragging: null, dropping: null}" @drop.prevent="items=dragDropList(items, dragging, dropping)" @dragover.prevent="$event.dataTransfer.dropEffect = &quot;move&quot;">
    <div class="list-group mb-3">
      <template x-for="(item, index) in items" :key="index">
        <div class="position-relative list-group-item" draggable="true" :class="{'border border-primary': dragging === index}" @dragstart="dragging = index" @dragend="dragging = null">
          <div><i class="bi bi-grip-vertical"></i><span x-text="item"></span></a><button type="button" class="btn btn-outline-danger btn-sm float-end" aria-label="Delete" @click="items.splice(index, 1);"><i class="bi-trash"></i></button></div>
          <div class="position-absolute" style="top: 0; bottom: 0; right: 0; left: 0;" x-show.transition="dragging !== null" :class="{'bg-secondary': dropping === index}" @dragenter.prevent="if(index !== dragging) {dropping = index}" @dragleave="if(dropping === index) dropping = null"></div>
       <div class="input-group mt-2"><input type="text" class="form-control form-inline" x-model="newItem"></input><button class="btn btn-primary form-inline" x-bind:disabled="newItem == ''"  @click="items.push(newItem);newItem=''">Add Flavor</button></div>
  <p class="text-muted">The drag and drop logic comes from <a href="">alpine-sortable</a> by Ranjan Purbey but it turns out the CSS positioning is important for this to work and it wasn't obvious how to convert from Tailwind to Bootstrap.</p>




                var dragDropList = function (items, dragging, dropping) {
  if (dragging !== null && dropping !== null) {
    if (dragging < dropping) {
      items = [
        ...items.slice(0, dragging),
        ...items.slice(dragging + 1, dropping + 1),
        ...items.slice(dropping + 1)
    } else {
      items = [
        ...items.slice(0, dropping),
        ...items.slice(dropping, dragging),
        ...items.slice(dragging + 1)
    dropping = null;
  return items;