Skip to content

KRate

Used for rating.

Install

bash
pnpm add @ikun-ui/rate
bash
yarn add @ikun-ui/rate
bash
npm install @ikun-ui/rate

Basic usage

Use colors prop to set color for different level.

With allowHalf

Add attribute allowHalf Half star allowed.

With text

Using text to indicate rating score.

Add attribute showText to display text at the right of Rate. You can assign texts for different scores using texts.

ShowScore and ScoreTemplate

Add attribute showScore to display score at the right of Rate. You can customize score display by set scoreTemplate, which is a string and internally uses {value} to represent the score.

Clearable

You can reset the value to 0 when you click at the same value again.

More icons

You can use different icons to distinguish different rate components.

You can customize icons by passing icons.

Readonly

Read-only Rate is for displaying rating score. Half star is supported.

Use attribute readonly to make the component read-only. Add readonlyVoidIcon and readonlyVoidColor to set unselected icons and colors.

Sizes

Add size attribute to change the size of Rate. It supports sm, md and lg.

Rate Props

NameTypeDefaultDescription
maxnumber5max rating score.
valuenumber0rate value.
allowHalfbooleanfalsewhether picking half start is allowed.
showScorebooleanfalsewhether to display current score. showScore and showText cannot be true at the same time.
scoreTemplatestring'{value}'score template.
showTextbooleanfalsewhether to display texts.
textsstring / Record<number, string>''text or text map.
textColorstring'var(--ikun-zinc-500)'color of texts.
iconsstring / Record<number, string>'k-rate--active-icon'icon or icons map, alias i-carbon-star-filled to k-rate--active-icon.
colorsstring / Record<number, string>'var(--ikun-amber-500)'color or colors map.
voidIconstring'k-rate--void-icon'void icon, alias i-carbon-star to k-rate--void-icon.
voidColorstring'var(--ikun-stone-300)'void icon color.
disabledbooleanfalsewhether rate is disabled.
readonlybooleanfalsewhether rate is readonly.
readonlyVoidIconstring'k-rate--readonly-icon'readonly void icon, alias i-carbon-star-filled to k-rate--readonly-icon.
readonlyVoidColorstring'var(--ikun-light-700)'readonly void icon color.
clearablebooleanfalsewhether value can be reset to 0.
sizesm | md |lgmdsize of rate.
clsstring-Additional class
attrsRecord<string, string>{}Additional attributes

Rate Events

NameDescriptionType
updateValueEvent fired when the value is changes.(event: Event)=> void

MIT Licensed