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.


                <link rel="stylesheet" href="">
<script type="module" src=""></script>
<script defer src=""></script>

<div id="app" class="p-8" x-data="{ showDrawer: false }">

  <h1 class="text-2xl mb-4">Using <a href="" class="text-blue-600">Shoelace Components</a> with Alpine</h1>

       @sl-after-hide="showDrawer=true; setTimeout(() => showDrawer = false, 3000)"
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    <sl-button slot="footer" type="primary" @click="$refs.drawer.hide()">Close</sl-button>
  <div class="mt-4 flex w-1/2 space-x-4"> 
    <sl-button size="small" pill @click="$">Open Drawer</sl-button>
    <sl-button size="small" pill @click="$">Open Dialog</sl-button>
    <p class="w-1/2 px-4 py-2 mt-4 bg-yellow-200 text-gray-800"
    I only display after the drawer closes.
  <sl-dialog label="Dialog" class="dialog-overview" x-ref="dialog">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
       <sl-button @click="$refs.dialog.hide()" slot="footer" type="primary">Close</sl-button>


  <div class="mt-8" x-data="{ loading: false }">
    <h2 class="text-xl">Toggle Loading States</h2>

      <div class="space-y-4">
      <sl-switch :checked="loading"                  
                 x-text="loading ? 'Loading' : 'Not Loading'" 
                 @sl-change="loading = !loading">

      <p x-text="`Loading: ${loading}`"></p>
          <sl-button type="primary" :loading="loading" x-text="loading ? 'Loading' : 'Not Loading'"></sl-button>

<!--  Form with x-model  -->
  <div class="mt-12 bg-gray-50 py-4 px-6" 
        x-data="{ form: { name: 'Bob', checked: true } }">
    <h3 class="text-gray-400 py-4">Uses x-model to bind data to the input element.</h3>
    <sl-form @sl-submit="$" class="test-form">
      <sl-input name="name" type="text" label="Name" x-model=""></sl-input>
    <!-- x-model doesn't work with sl-checkbox -->
<!--     <sl-checkbox @sl-change="form.checked = !form.checked" checked>Agree</sl-checkbox> 
      <sl-checkbox @sl-change="form.checked = !form.checked" checked>Agree</sl-checkbox>
      <sl-button submit>Submit</sl-button>
    <div class="mt-8 text-gray-500">      
      <p>Form Data: <span x-text="JSON.stringify(form)"></span></p>
    <sl-dialog x-ref="confirmed">
      <h2 class="text-center text-2xl">Thank you!</h2>
      <p x-text="`Name: ${}`"></p>
      <p x-text="`Agree: ${form.checked}`"></p>
      <sl-button @click="$refs.confirmed.hide()" slot="footer" type="primary">Close</sl-button>


                [x-cloak] { display: none !important; }