Skip to content

SortButton

A sorting button component that supports three states: ascending, descending, and reset.

Component Types

Basic Usage

Use v-model to bind the current sorting state. Values are -1, 0, and 1, representing descending, reset state, and ascending respectively.

html
<wd-sort-button v-model="value" title="Price" @change="handleChange" />
ts
const value = ref(0)

function handleChange({ value }) {
  console.log(value)
}

Component Variants

Allow Reset

Setting allow-reset allows the sort button to return to the reset state.

html
<wd-sort-button v-model="value" title="Price" allow-reset />

Descending First

Setting desc-first makes the first switch prioritize entering descending order.

html
<wd-sort-button v-model="value" title="Price" desc-first />

Component Styles

Show Underline

Setting line displays an underline.

html
<wd-sort-button v-model="value" title="Price" line />

Attributes

ParameterDescriptionTypeDefault Value
model-value / v-modelCurrent sort direction value. 1 for ascending, 0 for reset state, -1 for descendingSortButtonValue0
titleSort button textstring''
allow-resetWhether to allow reset to unselected statebooleanfalse
desc-firstWhether to prioritize switching to descending orderbooleanfalse
lineWhether to show underlinebooleanfalse
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

Events

Event NameDescriptionParameters
changeTriggered when sort direction changes{ value }

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-sort-button-height$n-48组件高度
--wot-sort-button-text-font-size$typography-body-size-main文字字号
--wot-sort-button-text-line-height$typography-body-line--height-size-main文字行高
--wot-sort-button-arrow-icon-size$n-24箭头图标尺寸
--wot-sort-button-right-size$n-16右侧区域尺寸
--wot-sort-button-icon-color$icon-auxiliary图标颜色
--wot-sort-button-icon-color-active$primary-6图标激活颜色
--wot-sort-button-color$text-secondary文字颜色
--wot-sort-button-color-active$text-main文字激活颜色
--wot-sort-button-font-weight-active$font-weight-medium文字激活字重
--wot-sort-button-line-width$n-24下划线宽度
--wot-sort-button-line-height$n-4下划线高度
--wot-sort-button-line-color$primary-6下划线颜色
--wot-sort-button-line-bottom$spacing-ultra-tight下划线底部距离
--wot-sort-button-right-spacing-left$spacing-extra-tight右侧区域左间距
--wot-sort-button-sort-spacing$spacing-ultra-tight排序图标纵向间距

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.