Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <!--
  Forked from:
  https://quasar.dev/vue-components/tab-panels#Example--Coloring
-->
<div id="q-app">
  <div class="q-pa-md">
    <div class="q-gutter-y-md" style="max-width: 600px">
      <q-card>
        <q-form @submit.native="onSubmit" @reset="onReset" greedy> 
          <q-tabs
            v-model="tab"
            class="bg-purple text-white"
            align="justify"
            narrow-indicator
          >
            <q-tab :alert="validators.nameErr ? 'red': false" icon="mail" name="name" label="Name" ></q-tab>
            <q-tab :alert="validators.ageErr ? 'red': false" icon="alarm" name="age" label="Age" ></q-tab>
            <q-tab icon="movie" name="terms" label="Terms" >
              <q-badge v-if="validators.formHasError" color="red" floating>{{validators.errCount}}</q-badge>
            </q-tab>
          </q-tabs>

          <q-separator ></q-separator>

          <q-tab-panels v-model="tab" animated class="bg-purple-1 text-center" keep-alive ref="tabs">
            <q-tab-panel name="name">
              <q-input
                ref="name"
                filled
                v-model="name"
                label="Your name *"
                hint="Name and surname"
                lazy-rules
                :rules="[ val => val && val.length > 0 || 'Please type something']"
                       name="name"
              ></q-input>
            </q-tab-panel>

            <q-tab-panel name="age" class="bg-purple-2">
              <q-input
                ref="age"
                filled
                type="number"
                v-model="age"
                label="Your age *"
                lazy-rules
                       name="age"
                :rules="[
                  val => val !== null && val !== '' || 'Please type your age',
                  val => val > 0 && val < 100 || 'Please type a real age'
                ]"
              ></q-input>
            </q-tab-panel>

            <q-tab-panel name="terms">
              <q-toggle v-model="accept" label="I accept the license and terms" name="accept" ></q-toggle>
            </q-tab-panel>
          </q-tab-panels>
          <q-card-actions align="center">
            <div>
              <q-btn label="Submit" type="submit" color="primary"></q-btn>
              <q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" ></q-btn>
            </div>
          </q-card-actions>
        </q-form>          
      </q-card>
    </div>
  </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                const valObj = () => ({
  nameErr: false,
  ageErr: false,
  formHasError:false,
  errCount: 0
})

new Vue({
  el: '#q-app',
  data () {
    return {
      tab: 'name',
      accept: false,
      name: null,
      age: null,
      tabNames: ["name", "age", "terms"],
      validators: valObj()
    }
  },
  methods: {
    onSubmit (evt) {
      console.log('onSubmit')
      this.validators.errCount = 0
      this.validators.nameErr = this.$refs.name.hasError
      this.validators.ageErr = this.$refs.age.hasError
      this.validators.nameErr && this.validators.errCount++      
      this.validators.ageErr && this.validators.errCount++      
      !this.accept && this.validators.errCount++      
      if(this.validators.errCount > 0){
        this.validators.formHasError = true
        this.$q.notify({
          color: 'negative',
          message: 'Please fill in marked tabs with errors.'
        })
      }else if (!this.accept) {
        this.$q.notify({
          color: 'negative',
          message: 'You need to accept the license and terms first'
        })
      }
      else {
        this.validators.formHasError = false
        // create your formdata
        const formData = new FormData()
        // append the form inputs
        formData.append('name', this.name)
        formData.append('age', this.age)
        formData.append('accept', this.accept)
        console.log('formData=>')
        for (let key of formData.entries()) {
            console.log(key[0] + ', ' + key[1]);
        }
        // console.log('formData', formData)
        // here you submit your formData
        // using an http client.
        // eg: this.$axios.post('http://testsite.com/someApi/formsubmit', formData)
        this.$q.notify({
          icon: 'done',
          color: 'positive',
          message: 'Submitted'
        })
      }
    },

    onReset () {
      this.name = null
      this.age = null
      this.validators = valObj()
      this.$refs.name.resetValidation()
      this.$refs.age.resetValidation()
    },
    discoverTabs() {
      // traverse the tabs to discover its content
      let traversal = this.tabNames.reduce((promiseChain, item) => {
        return promiseChain.then(() => new Promise(resolve => {
              console.log("done with", item)
              resolve()
              this.$refs.tabs.goTo(item)
            })
        )
      }, Promise.resolve())
      
      traversal.then(() => {
        console.log("done")
        this.$refs.tabs.goTo('name')
      })
    }
  },
  mounted() {
    this.discoverTabs()
  }
})
              
            
!
999px

Console