본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Rate 별점

원문 보기 위키 갱신

Rate는 빠른 별점 평가나 리뷰 표시에 쓰는 컴포넌트예요. 반 개, 아이콘·개수·색상 커스텀까지 지원하죠.

출처: 문서

본문

설치

@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.

import { createApp } from 'vue'
import { Rate } from '@nutui/nutui'

const app = createApp()
app.use(Rate)

사용 예시

기본 사용법

demo: rate basic

반 개

demo: rate half

아이콘 커스터마이즈

demo: rate icon

개수 커스터마이즈

demo: rate count

색상 커스터마이즈

demo: rate color

비활성화

demo: rate disabled

읽기 전용

demo: rate read

이벤트 바인딩

demo: rate event

크기 커스터마이즈 35px

demo: rate size

API

Props

Attribute Description Type Default
v-model The current number of stars, you can use v-model to bind data in both directions number | string -
count Total number | string of stars number | string 5
active-color Icon selection color string #fa200c
void-color Icon unselected color string #ccc
allow-half half star boolean false
readonly read-only boolean false
disabled whether to disable boolean false
spacing spacing number | string 20
touchable Whether to allow select rate by touch gesture boolean true
size Icon custom size , eg 20px 2em 2rem number | string -
custom-icon custom Icon, set VNode VNode | h StarFillN

Events

Event Description Arguments
change An event that fires whenever the current score is modified val

Types v4.3.3

이 컴포넌트는 아래 타입 정의를 함께 내보내요.

import type {
  RateProps,
  RateInstance
} from '@nutui/nutui';

Theming

CSS Variables

스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.

Name Default Value
--nut-rate-icon-color var(--nut-primary-color)
--nut-rate-icon-void-color var(--nut-disable-color)

더 알아보기 (Learn more)