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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>
  <div class="inputs">
    <FormulateInput
      type="group"
      :repeatable="true"
      add-label="+ Add Beverage"
      v-model="values"
      #default="{ index }"
    >
      <div class="double">
        <FormulateInput
          type="select"
          name="beverage"
          label="Select a beverage"
          placeholder="Select one"
          validation="required"
          :options="{coffee: 'Coffee', tea: 'Tea', beer: 'Beer'}"
        />
        <FormulateInput
          type="select"
          name="variant"
          validation="required"
          placeholder="Select one"
          :label="label(index)"
          :options="beverageOptions(index)"
        />
      </div>
      <div>
        <FormulateInput
          v-if="values[index] && values[index].hasOwnProperty('variants') && values[index].variants === 'drip'"
          type="checkbox"
          name="roomForCream"
          label="Leave me room for cream"
        />
      </div>
    </FormulateInput>
    <pre>{{ values }}</pre>
  </div>
</template>

<script>
export default {
  data() {
    return {
      values: [{}],
      options: {
        coffee: {
          single: 'Single',
          double: 'Double',
          drip: 'Drip'
        },
        tea: {
          black: 'Black tea',
          camomile: 'Camomile',
          peppermint: 'Peppermint'
        },
        beer: {
          bitter: 'English bitter',
          pilsner: 'Pilsner',
          ipa: 'India Pale Ale'
        }
      }
    };
  },
  methods: {
    beverage (index) {
      return Array.isArray(this.values) &&
        this.values[index] &&
        this.values[index].beverage
    },
    label (index) {
      return this.beverage(index) ? `What type of ${this.beverage(index)}` : '----'
    },
    beverageOptions (index) {
      const type = this.beverage(index)
      const options = type ? this.options[type] : {}
      const values = this.values[index] || {}
      const variant = values.variant
      if (variant && !options[variant]) {
        this.values[index].variant = undefined
      }
      return options
    }
  }
};
</script>

<style lang="scss">
.inputs {
  background-color: white;
  max-width: 30em;
  padding: 2em;
  margin: 6.5em auto 2em auto;
  border-radius: 0.25em;
  box-shadow: 0 0 1em rgba(0, 0, 0, 0.25);
}
.double {
  display: flex;
  justify-content: space-between;
  
  .formulate-input {
    width: calc(50% - .5em);
    margin-bottom: 0;
  }
}
pre {
  display: block;
  background-color: #e7f6ef;
  padding: .25em;
  border-radius: .25em;
}
html {
  min-height: 100%;
}
body {
  padding: 2em;
  background-image: url("https://vueformulate.com/logo.svg"),
    linear-gradient(-45deg, #7ccea9, #ffffff);
  background-repeat: no-repeat;
  background-size: 3em, 100%;
  background-position: center 2em, center center;
}
</style>

              
            
!
999px

Console