RadioGroup

Demos

Sizes

Available size variant for the ui prop: s / m.

Normal size

Checked: -

Small size

Checked: -

Edit this page on GitHubEdit
<template>
<article>
  <section>
    <h4>Normal size</h4>
    <veui-radio-group
      v-model="flavor"
      :items="flavors"
    />
    <p>Checked: {{ readable }}</p>
  </section>
  <section>
    <h4>Small size</h4>
    <veui-radio-group
      v-model="flavor"
      ui="s"
      :items="flavors"
    />
    <p>Checked: {{ readable }}</p>
  </section>
</article>
</template>

<script>
import { RadioGroup } from 'veui'

export default {
  components: {
    'veui-radio-group': RadioGroup
  },
  data () {
    return {
      flavor: null,
      flavors: [
        { value: 'LATTE', label: 'Latte' },
        { value: 'MOCHA', label: 'Mocha' },
        { value: 'AMERICANO', label: 'Americano' }
      ]
    }
  },
  computed: {
    flavorLabelMap () {
      return this.flavors.reduce((map, { value, label }) => {
        map[value] = label
        return map
      }, {})
    },
    readable () {
      return this.flavorLabelMap[this.flavor] || '-'
    }
  }
}
</script>

<style lang="less" scoped>
section {
  margin-bottom: 20px;
}

h4 {
  margin-top: 0;
}
</style>

API

Props

NameTypeDefaultDescription
uistring=-

Style variants.

ValueDescription
sSmall.
mMedium.
itemsArray<Object>[]

The datasource of items with the item type being {label, value, disabled, ...}.

NameTypeDescription
labelstringThe descriptive label of the item.
value*The value of the item.
disabledboolean=Whether the item is disabled.
value*-

v-model

The value of the selected item.

disabledboolean=falseWhether the radio group is disabled.
readonlyboolean=falseWhether the radio group is read-only.

Slots

NameDescription
item

The label content of each radio. Displays the value of the label property by default.

NameTypeDescription
labelstringThe descriptive label of the item.
value*The value of the item.
indexnumberThe index of the item within items.
disabledboolean=Whether the item is disabled.

Additionally, custom properties apart from the listed ones will also be passes into the scope object via v-bind.

Events

NameDescription
change

v-model

Triggers when the selected item changed. The callback parameter list is (value: *) and value is the value of the selected item.

Edit this page on GitHubEdit