diff --git a/src/components/selectbutton/SelectButton.vue b/src/components/selectbutton/SelectButton.vue
index c4a3ade7f..3c28a3f49 100644
--- a/src/components/selectbutton/SelectButton.vue
+++ b/src/components/selectbutton/SelectButton.vue
@@ -18,11 +18,11 @@ export default {
props: {
value: null,
options: Array,
+ optionLabel: null,
+ multiple: Boolean,
disabled: Boolean,
dataKey: null,
name: String,
- multiple: Boolean,
- optionLabel: null,
optionValue: null,
optionDisabled: null
},
@@ -86,7 +86,7 @@ export default {
this.focusedIndex = index;
this.$emit('focus', event);
},
- onBlur() {
+ onBlur(event) {
this.focusedIndex = null
this.$emit('blur', event);
}
diff --git a/src/views/selectbutton/SelectButtonDemo.vue b/src/views/selectbutton/SelectButtonDemo.vue
index bd5be2bfe..aeb1a3aca 100644
--- a/src/views/selectbutton/SelectButtonDemo.vue
+++ b/src/views/selectbutton/SelectButtonDemo.vue
@@ -27,10 +27,14 @@
Selected Car: {{selectedCar}}
+
+
diff --git a/src/views/selectbutton/SelectButtonDoc.vue b/src/views/selectbutton/SelectButtonDoc.vue
new file mode 100644
index 000000000..c7dc87113
--- /dev/null
+++ b/src/views/selectbutton/SelectButtonDoc.vue
@@ -0,0 +1,226 @@
+
+
+
+
+ Import
+
+import SelectButton from 'primevue/selectbutton';
+
+
+ Getting Started
+ SelectButton requires a value to bind, optionLabel and a collection of options. How to define the options property; Providing an array of arbitrary objects along with the optionLabel property to specify the field name of the option.
+
+<SelectButton v-model="selectedCity" :options="cities" optionLabel="name" />
+
+
+
+export default {
+ data() {
+ return {
+ selectedCity: null,
+ cities: [
+ {name: 'London', code: 'LND'},
+ {name: 'Paris', code: 'PRS'},
+ {name: 'Rome', code: 'RM'}
+ ]
+ }
+ }
+}
+
+
+ Multiple
+ SelectButton allows selecting only one item by default and setting multiple option enables choosing more than one item. In multiple case, model property should be an array.
+
+<SelectButton v-model="selectedCity" :options="cities" optionLabel="brand" :multiple="true" />
+
+
+ Disabled Options
+ Particular options can be prevented from selection using the optionDisabled property.
+
+ Templating
+ Items support templating to display custom content inside the buttons using an template that receives the option as the implicit variable.
+
+
+<SelectButton v-model="selectedCar" :options="cars" optionLabel="brand">
+ <template #option="slotProps">
+ <div style="text-align: center; padding: 1em; width: 125px">
+ <img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" style="width:48px" />
+ <div style="margin-top: 1em">{{slotProps.option.brand}}</div>
+ </div>
+ </template>
+</SelectButton>
+
+
+
+ Properties
+
+
+
+
+ Name |
+ Type |
+ Default |
+ Description |
+
+
+
+
+ value |
+ any |
+ null |
+ Value of the component. |
+
+
+ options |
+ array |
+ null |
+ An array of objects to display as the available options. |
+
+
+ optionLabel |
+ string |
+ null |
+ Name of the label field of an option when an arbitrary objects instead of SelectItems are used as options. |
+
+
+ multiple |
+ boolean |
+ false |
+ When specified, allows selecting multiple values. |
+
+
+ disabled |
+ boolean |
+ false |
+ When present, it specifies that the element should be disabled. |
+
+
+ dataKey |
+ string |
+ null |
+ A property to uniquely match the value in options for better performance. |
+
+
+ name |
+ string |
+ null |
+ ??? |
+
+
+ optionValue |
+ any |
+ null |
+ ??? |
+
+
+ optionDisabled |
+ boolean |
+ null |
+ ??? |
+
+
+
+
+
+ Events
+
+
+
+
+ Name |
+ Parameters |
+ Description |
+
+
+
+
+ input |
+ event: Single value or an array of values that are selected. |
+ Callback to invoke on value change. |
+
+
+ focus |
+ event: Browser event |
+ Callback to invoke on focus. |
+
+
+ blur |
+ event: Browser event |
+ Callback to invoke on blur. |
+
+
+
+
+
+ Dependencies
+ None.
+
+
+
+
+ View on GitHub
+
+
+
+<template>
+ <div>
+ <div class="content-section introduction">
+ <div class="feature-intro">
+ <h1>SelectButton</h1>
+ <p>SelectButton is a form component to choose a value from a list of options using button elements.</p>
+ </div>
+ </div>
+
+ <div class="content-section implementation">
+ <h3 class="first">Single</h3>
+ <SelectButton v-model="selectedCity" :options="cities" optionLabel="name" />
+ <p>Selected City: <span style="font-weight: bold">{{selectedCity}}</span></p>
+
+ <h3>Multiple</h3>
+ <SelectButton v-model="selectedCars" :options="cars" optionLabel="brand" :multiple="true" />
+ <p>Selected Cars: <span style="font-weight: bold">{{selectedCars}}</span></p>
+
+ <h3>Custom Content</h3>
+ <SelectButton v-model="selectedCar" :options="cars" optionLabel="brand">
+ <template #option="slotProps">
+ <div style="text-align: center; padding: 1em; width: 125px">
+ <img :alt="slotProps.option.brand" :src="'/demo/images/car/' + slotProps.option.brand + '.png'" style="width:48px" />
+ <div style="margin-top: 1em">{{slotProps.option.brand}}</div>
+ </div>
+ </template>
+ </SelectButton>
+ <p>Selected Car: <span style="font-weight: bold">{{selectedCar}}</span></p>
+ </div>
+ </div>
+</template>
+
+
+
+
+export default {
+ data() {
+ return {
+ selectedCity: null,
+ selectedCar: null,
+ selectedCars: null,
+ cities: [
+ {name: 'London', code: 'LND'},
+ {name: 'Paris', code: 'PRS'},
+ {name: 'Rome', code: 'RM'}
+ ],
+ cars: [
+ {brand: 'Audi', key: 'A'},
+ {brand: 'Bmw', key: 'B'},
+ {brand: 'Mercedes', key: 'M'}
+ ]
+ }
+ },
+ created() {
+ this.selectedCar = this.cars[1];
+ }
+}
+
+
+
+
+
\ No newline at end of file