Rate

Used for rating

Basic usage

Rate divides rating scores into several levels and these levels can be distinguished by using different background colors. By default background colors are the same, but you can assign them an array with three element to reflect three levels using the colors attribute, and their two thresholds can be defined by low-threshold and high-threshold, or you can assign them with a object which key is the threshold between two levels and value is the corresponding color.

Sizes

With allow-half

Add attribute allow-half Half star allowed

With text

Using text to indicate rating score

Add attribute show-text to display text at the right of Rate. You can assign texts for different scores using texts. texts is an array whose length should be equal to the max score max.

More icons

You can use different icons to distinguish different rate components.

You can customize icons by passing icons an array with three elements or a object which key is the threshold between two levels and value is the corresponding icon. In this example, we also use void-icon to set the icon if it is unselected.

Read-only

Read-only Rate is for displaying rating score. Half star is supported.

Use attribute disabled to make the component read-only. Add show-score to display the rating score at the right side. Additionally, you can use attribute score-template to provide a score template. It must contain {value}, and {value} will be replaced with the rating score.

Custom styles

Now you can set custom style for rate component. Use css/scss language to change the global or local color. We set some global color variables: --b-rate-void-color, --b-rate-fill-color, --b-rate-disabled-void-color, --b-rate-text-color. You can use like: :root { --b-rate-void-color: red; --b-rate-fill-color: blue; }.

Default Variables

VariableDefault Color
--b-rate-void-colorvar(--b-color-neutral-4)
--b-rate-fill-colorvar(--b-color-yellow-3)
--b-rate-disabled-void-colorvar(--b-color-neutral-3)
--b-rate-text-colorvar(--b-color-neutral-9)

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
model-value / v-modelbinding valuenumber0
maxmax rating scorenumber5
sizesize of Ratestringlarge / default / smalldefault
disabledwhether Rate is read-onlybooleanfalse
allow-halfwhether picking half start is allowedbooleanfalse
low-thresholdthreshold value between low and medium level. The value itself will be included in low levelnumber2
high-thresholdthreshold value between medium and high level. The value itself will be included in high levelnumber4
colorscolors for icons. If array, it should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding colorarray/object['#F7BA2A', '#F7BA2A', '#F7BA2A']
void-colorcolor of unselected iconsstring#C6D1DE
disabled-void-colorcolor of unselected read-only iconsstring#EFF2F7
iconsicon components. If array, ot should have 3 elements, each of which corresponds with a score level, else if object, the key should be threshold value between two levels, and the value should be corresponding icon componentarray/object[StarFilled, StarFilled, StarFilled]
void-iconcomponent of unselected iconsstring/componentStar
disabled-void-iconcomponent of unselected read-only iconsstring/componentStarFilled
show-textwhether to display textsbooleanfalse
show-scorewhether to display current score. show-score and show-text cannot be true at the same timebooleanfalse
text-colorcolor of textsstring#1F2D3D
textstext arrayarray['Extremely bad', 'Disappointed', 'Fair', 'Satisfied', 'Surprise']
score-templatescore templatestring{value}

Events

Event NameDescriptionParameters
changeTriggers when rate value is changedvalue after changing
Last Updated:
Contributors: Tam Mai