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

              
                <!--
  Forked from:
  http://localhost:9090/vue-components/select#Example--Option-group
  To Do: Recursive expansion of nested children
  See https://codepen.io/mickey58/pen/yLJEJNG 
  
  New feauture added below:
    - Allow selection of first level (group), not only selection of a child
    - Done by @click="model = scope.opt.label"
   -  Problem: This does not work in combination with expand-icon-toggle 
      (which in  theory should allow selection of an item on first level from its   expansion)

  Note: With selection 'multiple', the simple "model = value" needs to be replaced
  by an array push operation
-->
<div id="q-app">
  <div class="q-pa-md" style="max-width: 300px">
      <div class="q-gutter-md">
        <q-badge color="secondary" multi-line>
          model: "{{ model }}"
        </q-badge>
  
        <q-select
          filled
          options-dense
          v-model="model"
          :options="options"
          label="Standard"
          color="teal"
          clearable
          options-selected-class="text-deep-orange"
          
        >
          <template v-slot:option="scope">
            <q-expansion-item
              dense
              expand-separator
              group="somegroup"
              :default-opened="hasChild(scope)"
               header-class="text-weight-bold"
              :label="scope.opt.label"
              @click="model = scope.opt.label"
            >
              <template v-for="child in scope.opt.children">
                <q-item
                  dense
                  :key="child.label"
                  clickable
                  v-ripple
                  v-close-popup
                  @click="model = child.label"
                  :class="{ 'bg-light-blue-1': model === child.label }"
                >
                  <q-item-section>
                    <q-item-label v-html="child.label" class="q-ml-md" ></q-item-label>
                  </q-item-section>
                </q-item>
              </template>
            </q-expansion-item>
          </template>
        </q-select>
      </div>
    </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                new Vue({
  el: '#q-app',
  data () {
    return {
      model: null,
      options: [
        {
          label: 'American cars',
          children: [
            {
              label: 'Ford'
            },
            {
              label: 'General Motors'
            },
            {
              label: 'Tesla'
            }
          ]
        },
        {
          label: 'German cars',
          children: [
            {
              label: 'Audi'
            },
            {
              label: 'BMW'
            },
            {
              label: 'Porsche'
            }
          ]
        },
        {
          label: 'Italian cars',
          children: [
            {
              label: 'Ferrari'
            },
            {
              label: 'Lamborghini'
            },
            {
              label: 'Maserati'
            }
          ]
        },
        {
          label: 'Japanese cars',
          children: [
            {
              label: 'Honda'
            },
            {
              label: 'Nissan'
            },
            {
              label: 'Toyota'
            }
          ]
        },
        {
          label: 'Option without children',
          children: [
          ]
        }
      ]
    }
  },

  methods: {
    getLabel (scope) {
      debugger
      console.log(scope)
      return scope.label
    },
    hasChild (scope) {
      return scope.opt.children.some(c => c.label === this.model)
    }
  }
})
              
            
!
999px

Console