Back to Ant Design

Rate

components/rate/index.zh-CN.md

6.3.72.1 KB
Original Source

何时使用 {#when-to-use}

  • 对评价进行展示。
  • 对事物进行快速的评级操作。

代码演示 {#examples}

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">基本</code> <code src="./demo/size.tsx" version="6.0.0">尺寸</code> <code src="./demo/half.tsx">半星</code> <code src="./demo/text.tsx">文案展现</code> <code src="./demo/disabled.tsx">只读</code> <code src="./demo/clear.tsx">清除</code> <code src="./demo/character.tsx">其他字符</code> <code src="./demo/character-function.tsx">自定义字符</code> <code src="./demo/component-token.tsx" debug>组件 Token</code>

API

通用属性参考:通用属性

属性说明类型默认值版本
allowClear是否允许再次点击后清除booleantrue
allowHalf是否允许半选booleanfalse
character自定义字符ReactNode | (RateProps) => ReactNode<StarFilled />function(): 4.4.0
className自定义样式类名string-
countstar 总数number5
defaultValue默认值number0
disabled只读,无法进行交互booleanfalse
keyboard支持使用键盘操作booleantrue5.18.0
size星星尺寸'small' | 'medium' | 'large''medium'
style自定义样式对象CSSProperties-
tooltips自定义每项的提示信息TooltipProps[] | string[]-
value当前数,受控值number-
onBlur失去焦点时的回调function()-
onChange选择时的回调function(value: number)-
onFocus获取焦点时的回调function()-
onHoverChange鼠标经过时数值变化的回调function(value: number)-
onKeyDown按键回调function(event)-

方法

名称描述
blur()移除焦点
focus()获取焦点

主题变量(Design Token){#design-token}

<ComponentTokenTable component="Rate"></ComponentTokenTable>