2016-07-21 10:10:04 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
group: Data Entry
|
2016-07-21 10:10:04 +08:00
|
|
|
title: Rate
|
2022-11-30 20:14:41 +08:00
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*oyOcTrB12_YAAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*M7_ER7GJr6wAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
demo:
|
|
|
|
cols: 2
|
2016-07-21 10:10:04 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
Rate component.
|
|
|
|
|
2016-09-10 13:43:30 +08:00
|
|
|
## When To Use
|
2016-07-21 10:10:04 +08:00
|
|
|
|
2016-11-16 21:33:37 +08:00
|
|
|
- Show evaluation.
|
2016-07-21 10:10:04 +08:00
|
|
|
- A quick rating operation on something.
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
## Examples
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
<code src="./demo/basic.tsx">Basic</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>
|
2023-05-18 13:53:51 +08:00
|
|
|
<code src="./demo/component-token.tsx" debug>Component Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2016-07-21 10:10:04 +08:00
|
|
|
## API
|
|
|
|
|
2020-06-28 22:41:59 +08:00
|
|
|
| Property | Description | type | Default | Version |
|
|
|
|
| --- | --- | --- | --- | --- |
|
2020-07-01 16:21:56 +08:00
|
|
|
| allowClear | Whether to allow clear when click again | boolean | true | |
|
|
|
|
| allowHalf | Whether to allow semi selection | boolean | false | |
|
|
|
|
| autoFocus | If get focus when component mounted | boolean | false | |
|
|
|
|
| character | The custom character of rate | ReactNode \| (RateProps) => ReactNode | <StarFilled /> | function(): 4.4.0 |
|
|
|
|
| className | The custom class name of rate | string | - | |
|
|
|
|
| count | Star count | number | 5 | |
|
|
|
|
| defaultValue | The default value | number | 0 | |
|
|
|
|
| disabled | If read only, unable to interact | boolean | false | |
|
|
|
|
| style | The custom style object of rate | CSSProperties | - | |
|
|
|
|
| tooltips | Customize tooltip by each character | string\[] | - | |
|
|
|
|
| value | The current value | number | - | |
|
|
|
|
| onBlur | Callback when component lose focus | function() | - | |
|
|
|
|
| onChange | Callback when select value | function(value: number) | - | |
|
|
|
|
| onFocus | Callback when component get focus | function() | - | |
|
|
|
|
| onHoverChange | Callback when hover item | function(value: number) | - | |
|
|
|
|
| onKeyDown | Callback when keydown on component | function(event) | - | |
|
2017-12-01 19:28:41 +08:00
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
| Name | Description |
|
|
|
|
| ------- | ------------ |
|
|
|
|
| blur() | Remove focus |
|
|
|
|
| focus() | Get focus |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Rate"></ComponentTokenTable>
|