Skip to content

Rate Component ​

This component is generally used for satisfaction surveys and star rating scenarios.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Example ​

html
<!-- Global usage -->
<hy-rate v-model="value"></hy-rate>
ts
import { ref } from 'vue';

const value = ref(2);

Custom Styles ​

  • Use active-color to set the color of the selected stars
  • Use inactive-color to set the color of the unselected stars
  • Use gutter to set the spacing between stars; the left and right padding each take up half of the gutter
html
<hy-rate active-color="#FA3534" inactive-color="#b2b2b2" gutter="20"></hy-rate>

Custom Icons ​

  • Use active-icon to set the active icon
  • Use inactive-icon to set the inactive icon
html
<!-- Custom icon -->
<hy-rate :activeIcon="IconConfig.CHECK_MASK" :inactiveIcon="IconConfig.CHECK_MASK"></hy-rate>
<!-- Image URL -->
<hy-rate
    activeIcon="https://pic1.imgdb.cn/item/67d6820788c538a9b5bf333a.png"
    inactiveIcon="https://pic1.imgdb.cn/item/67d6820788c538a9b5bf333b.png"
></hy-rate>
javascript
import { IconConfig } from '@hy-app/ui';

Maximum Rating ​

html
<hy-rate :count="10"></hy-rate>

Minimum Selectable Count ​

html
<hy-rate :minCount="5"></hy-rate>

Allow Half Stars ​

html
<hy-rate :value="2.5" allowHalf></hy-rate>

Disabled State ​

html
<hy-rate :value="2" disabled></hy-rate>

Readonly State ​

html
<hy-rate :value="2" readonly></hy-rate>

API ​

Rate Props ​

ParameterDescriptionTypeDefault
v-modelTwo-way binding for the number of selected starsnumber1
countMaximum number of selectable starsnumber5
disabledWhether user interaction is disabledbooleanfalse
readonlyWhether it is readonlybooleanfalse
sizeSize of the stars, in rpxnumber|string18
inactiveColorColor of unselected starsstring#b2b2b2
activeColorColor of selected starsstring#FFF00D
gutterDistance between starsnumber4
minCountMinimum number of selected starsnumber1
allowHalfWhether half-star selection is allowedbooleanfalse
activeIconIcon name when selectedstringSTAR_FILL
inactiveIconIcon name when unselectedstringSTAR
touchableWhether the rating can be selected via swipe gesturebooleantrue
customStyleCustom styleCSSProperties-

Events ​

Event NameDescriptionCallback Parameters
changeTriggered when the selected star changesvalue: the current number of selected stars. If using v-model for two-way binding, there is no need to listen to this event
12:33
battery