A slot allows you to display an element in the child that is controlled by the parent. This helps make your components reusable. For example, let's say you have a child component that displays data as a line chart, with the prop:chartData='chartData'. In terms of final output, slots perform a similar function as props in Vue — getting data from a parent component to a child component. However, whereas props pass data values to the component, slots can just pass direct template code. I think that this comes with a few benefits depending on the situation. Vue Select leverages scoped slots to allow for total customization of the presentation layer. Slots can be used to change the look and feel of the UI, or to simply swap out text. # footer 3.8.0+ Displayed at the bottom of the component, below.vsdropdown-toggle.
![Vue Vue](https://raw.githubusercontent.com/ParadeTo/vue-tree-list/master/img/demo.gif)
Displayed at the bottom of the component, below .vs__dropdown-toggle
.
When implementing this slot, you'll likely need to use appendToBody
to position the dropdown.Otherwise content in this slot will affect it's positioning.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search textdeselect {function}
- function to deselect an option
Slots Vs Props Vue Online
#header
3.8.0+
Displayed at the top of the component, above .vs__dropdown-toggle
.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search textdeselect {function}
- function to deselect an option
#list-footer
3.8.0+
Displayed as the last item in the dropdown. No content by default. Parent element is the
- ,so this slot should contain a root
.
Slots Vs Props Vue On Tv
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search text
#
list-header
3.8.0+Displayed as the first item in the dropdown. No content by default. Parent element is the
- ,so this slot should contain a root
.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search text
#
no-options
The no options slot is displayed above
list-footer
in the dropdown whenfilteredOptions.length 0
.search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searching
#
open-indicator
The open indicator is the caret icon on the component used to indicate dropdown status.
#
option
The current option within the dropdown, contained within
- .
option {Object}
- The currently iterated option fromfilteredOptions
#
search
The search input has a lot of bindings, but they're grouped into
attributes
andevents
. Mostof the time, you will just be binding those two withv-on='events'
andv-bind='attributes'
.If you want the default styling, you'll need to add
.vs__search
to the input you provide.#
selected-option
![Props Props](https://custom-images.strikinglycdn.com/res/practicaldev/image/fetch/s--1l_xVym2--/c_imagga_scale,f_auto,fl_progressive,h_900,q_auto,w_1600/https://thepracticaldev.s3.amazonaws.com/i/e1gmvpw1dm7jkxtsqtf5.png)
Displayed at the bottom of the component, below .vs__dropdown-toggle
.
When implementing this slot, you'll likely need to use appendToBody
to position the dropdown.Otherwise content in this slot will affect it's positioning.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search textdeselect {function}
- function to deselect an option
Slots Vs Props Vue Online
#header
3.8.0+
Displayed at the top of the component, above .vs__dropdown-toggle
.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search textdeselect {function}
- function to deselect an option
#list-footer
3.8.0+
Displayed as the last item in the dropdown. No content by default. Parent element is the
- ,so this slot should contain a root
.
Slots Vs Props Vue On Tv
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search text
#
list-header
3.8.0+Displayed as the first item in the dropdown. No content by default. Parent element is the
- ,so this slot should contain a root
.
search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searchingfilteredOptions {array}
- options filtered by the search text
#
no-options
The no options slot is displayed above
list-footer
in the dropdown whenfilteredOptions.length 0
.search {string}
- the current search queryloading {boolean}
- is the component loadingsearching {boolean}
- is the component searching
#
open-indicator
The open indicator is the caret icon on the component used to indicate dropdown status.
#
option
The current option within the dropdown, contained within
- .
option {Object}
- The currently iterated option fromfilteredOptions
#
search
The search input has a lot of bindings, but they're grouped into
attributes
andevents
. Mostof the time, you will just be binding those two withv-on='events'
andv-bind='attributes'
.If you want the default styling, you'll need to add
.vs__search
to the input you provide.#
selected-option
The text displayed within
selected-option-container
.This slot doesn't exist if
selected-option-container
is implemented.Slots Vs Props Vue Free
option {Object}
- A selected option
#
selected-option-container
This is the root element where
v-for='option in selectedValue'
. Most of the time you'll want touseselected-option
, but this container is useful if you want to disable the deselect button,or have fine grain control over the markup.Slots Vs Props Vue App
option {Object}
- Currently iterated selected optiondeselect {Function}
- Method used to deselect a given option whenmultiple
is truedisabled {Boolean}
- Determine if the component is disabledmultiple {Boolean}
- If the component supports the selection of multiple values
#
spinner
loading {Boolean}
- if the component is in a loading state