Skip to content

TStarRating / 星级评分

StarRating for collecting or displaying ratings. Supports half-stars, custom icons (star/heart/ghost/circle), labels, scores, and read-only mode. / 星级评分用于收集或展示评分,支持半星、自定义图标、文字标签、分数展示和只读模式。

Props / 属性

PropType / 类型Default / 默认值Description / 说明
modelValuenumber0v-model rating value
maxnumber5Maximum rating
size'sm' | 'default' | 'md' | 'lg''default'Size
colorstringActive color
icon'star' | 'heart' | 'ghost' | 'circle''star'Icon type
readonlybooleanfalseRead-only mode
allowHalfbooleanfalseAllow half-star selection
showTextbooleanfalseShow descriptive text
clearablebooleantrueAllow clearing by clicking again
showScorebooleanfalseShow numeric score

Basic Usage / 基础用法

vue
<script setup lang="ts">
import { TStarRating } from '@gulcc/tabler-vue'

const rating = ref(3)
</script>

<template>
  <TStarRating v-model="rating" />
</template>

Tips / 避坑指南

  • allowHalf enables half-star increments (0.5 steps)
  • clearable allows the user to click the same rating again to clear it
  • Customize display text via texts array (e.g., ['Bad', 'OK', 'Good', 'Great'])
  • Score template format: '{value}/{max} 分' — customize via scoreTemplate prop