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.


                    <script src=""></script>
    <div id="app">
      <!-- v-for -->
        <!-- Dynamic classes -->
        <!-- isFavがtrueのbookにfavクラスを付与 -->
        <!-- bookを関数に渡すことでdataにアクセス可能 -->
        <li v-for="book in filteredBooks" v-bind:class="{ fav: book.isFav}" @click="toggleFav(book)">

          <img v-bind:src="book.img" alt="book.title">


                      body {
        background-color: #eee;
        max-width: 960px;
        margin: 20px auto;
      p,h3,ul {
        margin: 0;
        padding: 0;
      li {
        list-style-type: none;
        background-color: #fff;
        margin: 20px auto;
        padding: 10px 20px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
      li.fav {
        background-color: teal;



                const app = Vue.createApp({
  // data, functions
  data() {
    return {
      books: [
          title: "本のタイトル1",
          author: "著者1",
          img: "assets/1.jpg",
          isFav: true,
          title: "本のタイトル2",
          author: "著者2",
          img: "assets/2.jpg",
          isFav: false,
          title: "本のタイトル3",
          author: "著者3",
          img: "assets/3.jpg",
          isFav: true,
  methods: {
    toggleFav(book) {
      book.isFav = !book.isFav
  computed: {
    filteredBooks() {
      // isFavがtrueのもののみ抽出する
      return this.books.filter(book => book.isFav)

// mountで指定した範囲内でしかvueは動かない