Pen Settings

HTML

CSS

CSS Base

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

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

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.

Vue

              
                <template>
  <h1>Hello, Vue 3 Reactivity API! :)</h1>
  <hr>
  <p><strong>Counter:</strong> {{ counter }}</p>
  <button @click="counter++">+ Increment counter</button>
  <br><br>
  <button @click="counter--">- Decrement counter</button>
  <hr>
  <h3>Hello! My name is <mark>{{ person.name }}</mark>. I'm <mark>{{ person.age }}</mark> years old.</h3>
  <p>Edit person's name
    <input v-model="person.name" placeholder="name" /> and age
    <input v-model="person.age" placeholder="age" />
  </p>
  <hr>
  <p><strong>PI:</strong> {{ math.PI }}</p>
  <button @click="math.PI = 6.28">Double PI</button> <span>(The console output after the button is clicked: <em>"Set operation on key 'PI' failed: target is readonly."</em>)</span>
  <hr>
  <h3>Alphabet Numbers</h3>
  <table>
    <tr>
      <th>Letter</th>
      <th>Number</th>
    </tr>
    <tr v-for="(value, key) in alphabetNumbers">
      <td>{{ key }}</td>
      <td>{{ value }}</td>
    </tr>
  </table>
  <br>
  <button @click="alphabetNumbers.B = 3">Change the value of B to 3</button><span> (Actually the letter B <em>is</em> changed to number 3 - <button @click="showValue">Show the value of B</button>, but it's <em>not</em> tracked by Vue.)</span>
</template>

<script>
  import { ref, reactive, readonly, markRaw, isRef, isReactive, isReadonly, isProxy, onMounted } from 'vue';
  
  export default {
    setup () {
      const counter = ref(0)
      const person = reactive({
        name: 'David',
        age: 36
      })
      const math = readonly({
        PI: 3.14
      })
      const alphabetNumbers = markRaw({
        A: 1,
        B: 2,
        C: 3
      })
      
      const showValue = () => {
        alert(`The value of B is ${alphabetNumbers.B}`)
      }
      
      onMounted(() => {
        console.log(isRef(counter)) // true
        console.log(isReactive(person)) // true
        console.log(isReadonly(math)) // true
        console.log(isProxy(alphabetNumbers)) // false
      })
      
      return {
        counter,
        person,
        math,
        alphabetNumbers,
        showValue
      }
    }
  }; 
</script> 

<style>
  table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
    padding: 5px;
  }
</style>

              
            
!
999px

Console