2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-05-17 02:29:37 +03:00
Files
vue-select/docs/api/props.md
T
Jeff Sagal dc91310860 Sass & Class Renames (#759)
* - add autoprefixer
- add cssnano
- add postcss-loader
- remove unused packages

* create RTL scss module

* add vs__ prefix to open-indicator, extract to module

* module for dropdown-toggle

* vs__clear module

* vs__dropdown-menu module

* rename `selected-tag` to `vs__selected`

* remove rtl class

* remove dropdown class

* search-input scss module

* move animations to global module

* refactor dropdown list items

* - spinner slot is now scoped with `loading` variable
- move spinner to scss module

* apply vs__search class directly to search input: if you're using the slot, you might not want default styles

* finish global modules

* make RTL a component state

* - update component states to use vs-- prefix
- rename dropdownClasses to stateClasses

* remove unused property

* Closes #760

* fix states

* more state fixes

* rename .close to vs__deselect

* - simplify dev.html
- start on 'sandbox' development

* update build

* - update webpack config
- move Sandbox to VuePress folder

* update external framework version links

* assign grid areas, ensure 100% height outside of docs

* limit specificity

* first pass at assigning variables

* assign 'darkest'

* remove max-height prop

* rename 'component' variables to 'state'

* update badges

* add deprecation notice to docs

* bump travis config

* add coveralls coverage reporter

* bump netlify config

* additional pass pulling up to variables

* start converting to SVG icons

* middle align action icons

* update netlify config

* netlify bump

* fix travis

* fix travis

* try lcov

* netlify attempt

* prune old packages

* bump travis config
2019-02-18 22:01:39 -08:00

5.7 KiB

value

Contains the currently selected value. Very similar to a value attribute on an <input>. You can listen for changes using 'change' event using v-on.

value: {
	default: null
},

options

An array of strings or objects to be used as dropdown choices. If you are using an array of objects, vue-select will look for a label key (ex. [{label: 'This is Foo', value: 'foo'}]). A custom label key can be set with the label prop.

options: {
	type: Array,
	default() {
		return [];
	}
},

disabled

Disable the entire component.

disabled: {
	type: Boolean,
	default: false
},

clearable

Can the user clear the selected property?

clearable: {
	type: Boolean,
	default: true
},

maxHeight

::: warning Deprecated in v2.x & Removed in v3.0 This prop was removed in v3.0. You can use the $vs-dropdown-max-height SCSS variable to adjust this setting in v3.x. :::

Sets the max-height property on the dropdown list.

maxHeight: {
	type: String,
	default: "400px"
},

searchable

Enable/disable filtering the options.

searchable: {
	type: Boolean,
	default: true
},

multiple

Equivalent to the multiple attribute on a <select> input.

multiple: {
	type: Boolean,
	default: false
},

placeholder

Equivalent to the placeholder attribute on an <input>.

placeholder: {
	type: String,
	default: ""
},

transition

Sets a Vue transition property on the .dropdown-menu. vue-select does not include CSS for transitions, you'll need to add them yourself.

transition: {
	type: String,
	default: "fade"
},

clearSearchOnSelect

Enables/disables clearing the search text when an option is selected.

clearSearchOnSelect: {
	type: Boolean,
	default: true
},

closeOnSelect

Close a dropdown when an option is chosen. Set to false to keep the dropdown open (useful when combined with multi-select, for example)

closeOnSelect: {
	type: Boolean,
	default: true
},

label

Tells vue-select what key to use when generating option labels when each option is an object.

label: {
	type: String,
	default: "label"
},

index

Tells vue-select what key to use when generating option values when each option is an object.

index: {
	type: String,
	default: null
},

getOptionLabel

Callback to generate the label text. If {option} is an object, returns option[this.label] by default.

Label text is used for filtering comparison and displaying. If you only need to adjust the display, you should use the option and selected-option slots.

getOptionLabel: {
	type: Function,
	default(option) {
		if (this.index) {
			option = this.findOptionByIndexValue(option);
		}

		if (typeof option === "object") {
			if (!option.hasOwnProperty(this.label)) {
				return console.warn(
					`[vue-select warn]: Label key "option.${this.label}" does not` +
						` exist in options object ${JSON.stringify(option)}.\n` +
						"http://sagalbot.github.io/vue-select/#ex-labels"
				);
			}
			return option[this.label];
		}
		return option;
	}
},

onChange

An optional callback function that is called each time the selected value(s) change. When integrating with Vuex, use this callback to trigger an action, rather than using v-model to retrieve the selected value.

onChange: {
	type: Function,
	default: function(val) {
		this.$emit("input", val);
	}
},

onTab

Select the current value if selectOnTab is enabled

onTab: {
	type: Function,
	default: function() {
		if (this.selectOnTab) {
			this.typeAheadSelect();
		}
	}
},

taggable

Enable/disable creating options from searchInput.

taggable: {
	type: Boolean,
	default: false
},

tabindex

Set the tabindex for the input field.

tabindex: {
	type: Number,
	default: null
},

pushTags

When true, newly created tags will be added to the options list.

pushTags: {
	type: Boolean,
	default: false
},

filterable

When true, existing options will be filtered by the search text. Should not be used in conjunction with taggable.

filterable: {
	type: Boolean,
	default: true
},

filterBy

Callback to determine if the provided option should match the current search text. Used to determine if the option should be displayed.

filterBy: {
	type: Function,
	default(option, label, search) {
		return (label | "").toLowerCase().indexOf(search.toLowerCase()) > -1;
	}
},

filter

Callback to filter results when search text is provided. Default implementation loops each option, and returns the result of this.filterBy.

filter: {
	type: Function,
	default(options, search) {
		return options.filter(option => {
			let label = this.getOptionLabel(option);
			if (typeof label === "number") {
				label = label.toString();
			}
			return this.filterBy(option, label, search);
		});
	}
},

createOption

User defined function for adding Options

createOption: {
	type: Function,
	default(newOption) {
		if (typeof this.mutableOptions[0] === "object") {
			newOption = { [this.label]: newOption };
		}
		this.$emit("option:created", newOption);
		return newOption;
	}
},

resetOnOptionsChange

When false, updating the options will not reset the select value

resetOnOptionsChange: {
	type: Boolean,
	default: false
},

noDrop

Disable the dropdown entirely.

noDrop: {
	type: Boolean,
	default: false
},

inputId

Sets the id of the input element.

inputId: {
	type: String
},

dir

Sets RTL support. Accepts ltr, rtl, auto.

dir: {
	type: String,
	default: "auto"
},

selectOnTab

When true, hitting the 'tab' key will select the current select value

selectOnTab: {
	type: Boolean,
	default: false
}