Skip to content

Rate

Used for Showrate

Basic Usage

Simply insert content using the default slot.

Default (no color distinction)
With color distinction
<template>
  <div flex>
    <div class="block">
      <span class="demonstration">Default (no color distinction)</span>
      <b-rate v-model="value1" allow-half show-text></b-rate>
    </div>
    <div class="block">
      <span class="demonstration">With color distinction</span>
      <b-rate v-model="value2" :colors="colors"></b-rate>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const value1 = ref(null)
const value2 = ref(null)
const colors = ['#99A9BF', '#F7BA2A', '#fa8c16']
</script>

<style scoped>
.block {
  padding: 30px 0;
  text-align: center;
  border-right: 1px solid #eff2f6;
  display: inline-block;
  width: 49%;
  box-sizing: border-box;
}
</style>

Customicon

<template>
  <div flex>
    <b-rate
      v-model="value"
      :icon-classes="iconClasses"
      void-icon-class="heart"
      :colors="['#99A9BF', '#F7BA2A', '#fa8c16']"
    ></b-rate>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const value = ref(null)
const iconClasses = ['heart-fill', 'heart-fill', 'heart-fill']
</script>

readonly

3.7
<template>
  <b-rate :model-value="3.7" disabled show-score text-color="#fa8c16" score-template="3.7"></b-rate>
</template>

<script setup lang="ts"></script>

Attributes

ParameterDescriptionTypeOptionsDefault
value / v-modelBound valuenumber0
maxMaximum scorenumber5
disabledWhether read-onlybooleanfalse
allow-halfWhether to allow half selectionbooleanfalse
low-thresholdThreshold between low and medium scores; the value itself falls into the low categorynumber2
high-thresholdThreshold between high and medium scores; the value itself falls into the high categorynumber4
colorsIcon color array with 3 elements, corresponding to 3 score levelsarray['#F7BA2A', '#F7BA2A', '#F7BA2A']
void-colorColor of unselected iconsstring#C6D1DE
disabled-void-colorColor of unselected icons when read-onlystring#EFF2F7
icon-classesIcon class name array with 3 elements, corresponding to 3 score levelsarray['star', 'star', 'star']
void-icon-classClass name of unselected iconsstringstar
disabled-void-icon-classClass name of unselected icons when read-onlystringstar
show-textWhether to show auxiliary text. If true, the text content corresponding to the current score is selected from the texts arraybooleanfalse
show-scoreWhether to show current score. show-score and show-text cannot both be truebooleanfalse
text-colorColor of auxiliary textstring#1F2D3D
textsAuxiliary text arrayarray['Terrible', 'Disappointed', 'Average', 'Satisfied', 'Amazing']
score-templateScore display templatestring

Events

Event NameDescriptionCallback Parameters
changeTriggers when score changesChanged score