Skip to content

Rate Component ​

Rate Component

Rate component is used for rating operations, supporting custom icons, colors, half selection and other features.

Basic Usage ​

Basic rate component usage, bind the rating value through v-model.

Basic Rating

Current value: 3

Disabled State

Show CodeArrow
CopyGitHub

Different Sizes ​

Rate component supports three sizes: small, default, and large.

Small Size

Default Size

Large Size

Show CodeArrow
CopyGitHub

Custom Icon ​

You can customize the icons of the rate component through the icon attribute, including unselected icon, half-selected icon, and selected icon.

Custom Icon Example 1

Custom Icon Example 2

Show CodeArrow
CopyGitHub

Custom Color ​

You can customize colors for different rating values through the color attribute.

Default Color

Custom Color

Show CodeArrow
CopyGitHub

Maximum Rating Value ​

Set the maximum rating value of the rate component through the max attribute, default is 5.

Default Max Value (5)

Custom Max Value (3)

Custom Max Value (10)

Show CodeArrow
CopyGitHub

Half Selection Mode ​

Rate component supports half selection mode by default, you can control whether to enable half selection through the is-half attribute.

Half Selection Enabled (Default)

Current value: 2.5

Half Selection Disabled

Current value: 3
Show CodeArrow
CopyGitHub

Custom Gap ​

You can set the gap between rating icons through the gap attribute, default is 5px.

Small Gap (2px)

Default Gap (5px)

Large Gap (15px)

Show CodeArrow
CopyGitHub

Event Handling ​

Rate component provides a change event that is triggered when the rating value changes.

Event Log:
Show CodeArrow
CopyGitHub

Rate API ​

Attributes ​

AttributeDescriptionTypeAccepted ValuesDefault
v-modelBinding valuenumber——
sizeSizestringsmall / default / largedefault
colorRating color configuration{ [key in number]?: string }——
iconCustom icon configuration{ empty?: string, half?: string, show?: string }——
gapIcon gapnumber—5
maxMaximum rating valuenumber—5
is-halfWhether to support half selectionboolean—true
disabledWhether disabledboolean—false

Events ​

Event NameDescriptionParameters
changeTriggered when rating value changes(value: number)

Style Variables ​

The rate component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$theme-color-primaryTheme color - Primary
$font-size-smallFont size - Small
$font-size-defaultFont size - Default
$font-size-largeFont size - Large

Released under the MIT License