diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index b7d79ae..35faa13 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -47,7 +47,8 @@ export default defineConfig({ { text: "Single Select", link: "/demo/single-select" }, { text: "Multiple Select", link: "/demo/multiple-select" }, { text: "Custom Option Slot", link: "/demo/custom-option-slot" }, - { text: "Pre-Selected Values (single & multi)", link: "/demo/pre-selected-values" }, + { text: "Custom Tag Slot", link: "/demo/custom-tag-slot" }, + { text: "Pre-Selected Values", link: "/demo/pre-selected-values" }, { text: "Disabled Options", link: "/demo/disabled-options" }, { text: "With Menu Header", link: "/demo/with-menu-header" }, { text: "With Complex Menu Filter", link: "/demo/with-complex-menu-filter.md" }, diff --git a/docs/demo/custom-tag-slot.md b/docs/demo/custom-tag-slot.md new file mode 100644 index 0000000..192cd1c --- /dev/null +++ b/docs/demo/custom-tag-slot.md @@ -0,0 +1,106 @@ +--- +title: 'Custom Tag Slot' +--- + +# Custom Tag Slot + +The following example demonstrates how to use the `VueSelect` component with a custom slot `#tag` when using the `isMulti` prop. + +::: info +Read more about available [slots here](../slots.md) and the `isMulti` prop [here](../props.md#isMulti). +::: + + + + + + + {{ option.username }} × + + + + + + +## Demo source-code + +```vue + + + + + + {{ option.username }} × + + + + + +``` diff --git a/docs/slots.md b/docs/slots.md index f41e841..8093e2b 100644 --- a/docs/slots.md +++ b/docs/slots.md @@ -14,7 +14,7 @@ If you are not familiar with Vue's slots, you can read more about them [here](ht **Type**: `slotProps: { option: Option }` -Customize the rendered HTML of an option inside the menu. You can use the slot props to retrieve the current menu option that will be rendered. +Customize the rendered template of an option inside the menu. You can use the slot props to retrieve the current menu option that will be rendered. ```vue @@ -30,7 +30,7 @@ Customize the rendered HTML of an option inside the menu. You can use the slot p **Type**: `slotProps: { option: Option }` -Customize the rendered HTML if a selected option (inside the select control). You can use the slot props to retrieve the current selected option. +Customize the rendered template if a selected option (inside the select control). You can use the slot props to retrieve the current selected option. ```vue @@ -42,11 +42,31 @@ Customize the rendered HTML if a selected option (inside the select control). Yo ``` +## tag + +**Type**: `slotProps: { option: Option, removeOption: () => void }` + +When using `isMulti` prop, customize the rendered template of a selected option. You can use the slot props to retrieve the current selected option and a function to remove it. + +```vue + + + + {{ option.label }} × + + + +``` + ## menu-header **Type**: `slotProps: {}` -Customize the rendered HTML for the menu header. This slot is placed **before** the options. +Customize the rendered template for the menu header. This slot is placed **before** the options. ```vue @@ -64,7 +84,7 @@ Customize the rendered HTML for the menu header. This slot is placed **before** **Type**: `slotProps: {}` -Customize the rendered HTML when there are no options matching the search, inside the menu. +Customize the rendered template when there are no options matching the search, inside the menu. ```vue @@ -80,7 +100,7 @@ Customize the rendered HTML when there are no options matching the search, insid **Type**: `slotProps: {}` -Customize the rendered HTML for the dropdown icon. Please note that the slot is placed **inside the button**, so you don't have to deal with attaching event-listeners. +Customize the rendered template for the dropdown icon. Please note that the slot is placed **inside the button**, so you don't have to deal with attaching event-listeners. ```vue @@ -96,7 +116,7 @@ Customize the rendered HTML for the dropdown icon. Please note that the slot is **Type**: `slotProps: {}` -Customize the rendered HTML for the clear icon. Please note that the slot is placed **inside the button**, so you don't have to deal with attaching event-listeners. +Customize the rendered template for the clear icon. Please note that the slot is placed **inside the button**, so you don't have to deal with attaching event-listeners. ```vue @@ -112,7 +132,7 @@ Customize the rendered HTML for the clear icon. Please note that the slot is pla **Type**: `slotProps: {}` -Customize the rendered HTML when the select component is in a loading state. By default, it displays a `` component. +Customize the rendered template when the select component is in a loading state. By default, it displays a `` component. ```vue diff --git a/src/Select.vue b/src/Select.vue index e701d1f..0cf4bbf 100644 --- a/src/Select.vue +++ b/src/Select.vue @@ -421,15 +421,24 @@ onBeforeUnmount(() => { - - {{ getMultiValueLabel(option) }} - + + + {{ getMultiValueLabel(selectedOption) }} + + + { border: 0; width: var(--vs-icon-size); height: var(--vs-icon-size); - fill: var(--vs-icon-color); + color: var(--vs-icon-color); background: none; outline: none; cursor: pointer; @@ -730,7 +739,7 @@ onBeforeUnmount(() => { border: 0; width: var(--vs-icon-size); height: var(--vs-icon-size); - fill: var(--vs-icon-color); + color: var(--vs-icon-color); background: none; outline: none; cursor: pointer;