Skip to content

Rate

This component is used for rating operations, such as product ratings, service reviews, and similar scenarios.

  • Supports half-star rating
  • Supports custom icons and colors
  • Supports clearing selected rating
  • Customizable star count and spacing

Notice

This component may have slight differences in appearance across platforms. Please refer to the actual effect.

Platform Differences

App (vue)App (nvue)H5Mini Program

Basic Usage

  • Bind the rating value via v-model, default value is 0.
  • Set the total number of stars via count, default is 5.
html
<see-rate v-model="value" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(3);
</script>

Half Star Rating

  • Set allowHalf to true to enable half-star rating.
html
<see-rate v-model="value" allowHalf />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(3.5);
</script>

Custom Icons

  • Set the active icon via icon.
  • Set the inactive icon via voidIcon.
html
<see-rate v-model="value" icon="♥" voidIcon="♡" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(3);
</script>

Custom Colors

  • Set the active color via color.
  • Set the inactive color via voidColor.
html
<see-rate v-model="value" color="#ff6b00" voidColor="#ddd" />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(4);
</script>

Clearable

  • Set isClearable to true to allow clicking the same rating again to clear it (value resets to 0).
html
<see-rate v-model="value" isClearable />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(3);
</script>

Disabled State

  • Set isDisabled to true to disable the rate component.
  • In disabled state, click events will not trigger, and the style will turn gray or reduce in transparency.
html
<see-rate v-model="value" isDisabled />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(3);
</script>

Readonly State

  • Set isReadonly to true to set the rate component to readonly state.
  • In readonly state, click events will not trigger, but the style remains unchanged. Suitable for displaying existing ratings.
html
<see-rate v-model="value" isReadonly />

<script lang="ts" setup>
import { ref } from 'vue';
const value = ref(4.5);
</script>

API

Props

ParameterDescriptionTypeDefaultOptional ValuesPlatform Notes
modelValueBinding valuenumber0--
countTotal number of starsnumber5Any positive integer-
sizeStar size (px)number24Any positive number-
isDisabledWhether disabledbooleanfalsetrue, false-
isReadonlyWhether readonlybooleanfalsetrue, false-
allowHalfWhether to allow half starbooleanfalsetrue, false-
isClearableWhether to allow clearingbooleanfalsetrue, false-
colorActive colorstring-Any CSS color value-
voidColorInactive colorstring-Any CSS color value-
iconActive iconstring'★'Any character or icon-
voidIconInactive iconstring'☆'Any character or icon-
gapStar spacing (px)number4Any positive number-
nameForm field namestring''--

Events

Event NameDescriptionCallback Parameters
onChangeTriggered when rating value changesvalue: Current rating value

Liao ICP No. 2025070134