Skip to content

Rate

Used for rating things.

Basic Usage

The rating starts with three levels by default, and color arrays can be used to differentiate scores and emotional tendencies.

Default:
Custom colors:
Basic Usage

Different Sizes

Use the size property to set the size of the rating component.

Different Sizes

Allow Half Selection

Set the allow-half property to allow half-star selection.

Allow Half Selection

Auxiliary Text

Set the show-text property to display auxiliary text, or show-score to display the score.

Fair
3.7 pts
Auxiliary Text

Clearable

Use the clearable property to reset the value to 0 when re-clicking the same value.

Clearable

Read-only

Set the disabled property to enable read-only mode, commonly used for displaying scores.

3.7
Read-only

Custom Icon

Customize the icon via the icon slot.

Custom Icon

Use in Nuxt

The Rate component fully supports Nuxt 3/4 SSR rendering. When used in a Nuxt project, the component is automatically imported.

Average Score:
4.5
Use in Nuxt

SSR Notes:

  • ✅ Star display and half-selection (allow-half) are fully supported.
  • ✅ Custom text and score display render accurately in SSR.
  • ✅ Color configurations (colors array) support server-side calculation.
  • ✅ Styles remain consistent across different sizes.

SSR Safety

During server-side rendering, the Rate component generates static star bit maps or SVG paths, ensuring that users can see the full rating status before JavaScript loads.

API

Rate Props

PropDescriptionTypeDefault
v-model / model-valueBinding valuenumber0
maxMaximum valuenumber5
disabledWhether it is read-onlybooleanfalse
allow-halfWhether half-selection is allowedbooleanfalse
clearableWhether to allow resetting by clicking the current valuebooleanfalse
show-textWhether to display auxiliary text, overrides scorebooleanfalse
show-scoreWhether to display current score; active only when show-text is falsebooleanfalse
text-colorAuxiliary text colorstring'#1f2d3d'
textsArray of auxiliary textsstring[]['Disappointing', 'Poor', 'Fair', 'Good', 'Excellent']
colorsActive rating colors; supports string or array (for <=2, <=4, and 5)string | string[]'#F7BA2A'
void-colorColor for unselected statusstring'#C6D1DE'
disabled-void-colorUnselected color when disabledstring'#EFF2F7'
sizeSize of rating icons'large' | 'default' | 'small''default'
score-templateDisplay template for scoresstring'{value}'

Rate Events

Event NameDescriptionCallback Parameters
changeTriggered when the value changes(value: number) => void

Rate Slots

Slot NameDescriptionParameters
iconCustom icon{ index: number, width: string, activeColor: string, voidColor: string }

Theme Variables

VariableDescriptionDefault
--yh-rate-void-colorUnselected color#c6d1de
--yh-rate-fill-colorSelected color#f7ba2a
--yh-rate-disabled-void-colorUnselected color when disabled#eff2f7
--yh-rate-text-colorAuxiliary text color#1f2d3d
--yh-rate-font-sizeAuxiliary text size14px
--yh-rate-icon-marginIcon spacing6px

Released under the MIT License.