Skip to content
On this page

Select

When there are too many options, use the drop-down menu to display and select content.

Basic usage

The value of the widely applicable base radio 'v-model' is the value of the 'value' attribute of the currently selected 'kl-option', via 'placeholder' The property can set the booth text, not set the default to: 'Please enter a keyword'

Please enter a keyword
<>
<template>
    <kl-select v-model="value">
        <kl-option value="胡桃"></kl-option>
        <kl-option value="夜兰"></kl-option>
        <kl-option value="七七"></kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
</script>

<style lang="scss" scoped>
* {
    margin-left: 5px;
}
</style>

Disabled select

Disable the entire selector component, add the 'disabled' attribute, and the entire selector is unavailable.

Please enter a keyword
<>
<template>
    <kl-select v-model="value" disabled>
        <kl-option value="胡桃"></kl-option>
        <kl-option value="夜兰"></kl-option>
        <kl-option value="七七"></kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
</script>

<style lang="scss" scoped>
* {
    margin-left: 5px;
}
</style>

Disabled option

In 'kl-option', set the 'disabled' value to 'true' to disable the option

Please enter a keyword
<>
<template>
    <kl-select v-model="value">
        <kl-option value="胡桃" disabled></kl-option>
        <kl-option value="夜兰"></kl-option>
        <kl-option value="七七"></kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
</script>

<style lang="scss" scoped>
* {
    margin-left: 5px;
}
</style>

Option label

The label of 'kl-option' can be set via the 'label' attribute of 'kl-option', or it can be written inside 'kl-option' without setting the default value of 'value'.

Please enter a keyword
<>
<template>
    <kl-select v-model="value">
        <kl-option value="胡桃">HuTao</kl-option>
        <kl-option value="夜兰" label="YeLan"></kl-option>
        <kl-option value="七七" label="QiQi"></kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
</script>

<style lang="scss" scoped>
* {
    margin-left: 5px;
}
</style>

Size

Use the 'size' property to change the size of the drop-down selection box. In addition to the default size, there are two other options: 'large', 'small'.

Please enter a keyword
Please enter a keyword
Please enter a keyword
<>
<template>
    <kl-select v-model="value2" size="large">
        <kl-option value="胡桃">HuTao</kl-option>
        <kl-option value="夜兰">YeLan</kl-option>
        <kl-option value="七七">QiQi</kl-option>
    </kl-select>
    <kl-select v-model="value1">
        <kl-option value="胡桃">HuTao</kl-option>
        <kl-option value="夜兰">YeLan</kl-option>
        <kl-option value="七七">QiQi</kl-option>
    </kl-select>
    <kl-select v-model="value3" size="small">
        <kl-option value="胡桃">HuTao</kl-option>
        <kl-option value="夜兰">YeLan</kl-option>
        <kl-option value="七七">QiQi</kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value1 = ref()
const value2 = ref()
const value3 = ref()
</script>

<style lang="scss" scoped>
* {
    margin-top: 5px;
}
</style>

Singles can be cleared

You can use the clear icon to clear the selection.

Set the 'clearable' property for 'kl-select' to empty the selector.

Please enter a keyword
<>
<template>
    <kl-select v-model="value" clearable>
        <kl-option value="胡桃"></kl-option>
        <kl-option value="夜兰"></kl-option>
        <kl-option value="七七"></kl-option>
    </kl-select>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const value = ref()
</script>

<style lang="scss" scoped>
* {
    margin-left: 5px;
}
</style>

API

Select Attribute

nameDescriptionTypeThe default value is
v-modelbinding valueboolean
disabledwhether Select is disabledbooleanfales
sizesize of Input(large/default/small)stringdefault
clearablewhether select can be clearedbooleanfalse
placeholderplaceholderstring

Option Attribute

nameDescriptionTypeThe default value is
valuevalue of optionstring / number / boolean / object
labellabel of option, same as value if omittedstring/number
disabledwhether option is disabledbooleanfalse
iconUse the icon icon as a label, not with textString

Select Event

NameDescriptionCallback parameters
changeTriggered only when the modelValue changesval
clearFires when the Clear button generated by the clearable property is clicked

Released under the MIT License.