Back to Ant Design

Rate

components/rate/index.en-US.md

6.3.72.1 KB
Original Source

When To Use

  • Show evaluation.
  • A quick rating operation on something.

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/size.tsx" version="6.0.0">Sizes</code> <code src="./demo/half.tsx">Half star</code> <code src="./demo/text.tsx">Show copywriting</code> <code src="./demo/disabled.tsx">Read only</code> <code src="./demo/clear.tsx">Clear star</code> <code src="./demo/character.tsx">Other Character</code> <code src="./demo/character-function.tsx">Customize character</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

PropertyDescriptionTypeDefaultVersion
allowClearWhether to allow clear when click againbooleantrue
allowHalfWhether to allow semi selectionbooleanfalse
characterThe custom character of rateReactNode | (RateProps) => ReactNode<StarFilled />function(): 4.4.0
classNameThe custom class name of ratestring-
countStar countnumber5
defaultValueThe default valuenumber0
disabledIf read only, unable to interactbooleanfalse
keyboardSupport keyboard operationbooleantrue5.18.0
sizeStar size'small' | 'medium' | 'large''medium'
styleThe custom style object of rateCSSProperties-
tooltipsCustomize tooltip by each characterTooltipProps[] | string[]-
valueThe current valuenumber-
onBlurCallback when component lose focusfunction()-
onChangeCallback when select valuefunction(value: number)-
onFocusCallback when component get focusfunction()-
onHoverChangeCallback when hover itemfunction(value: number)-
onKeyDownCallback when keydown on componentfunction(event)-

Methods

NameDescription
blur()Remove focus
focus()Get focus

Design Token

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