Rate
Rate component.
When To Use#
Show evaluation.
A quick rating operation on something.
Examples
import { Rate } from 'antd';
ReactDOM.render(<Rate />, mountNode);
import { Rate } from 'antd';
class Rater extends React.Component {
state = {
value: 3,
}
handleChange = (value) => {
this.setState({ value });
}
render() {
const { value } = this.state;
return (
<span>
<Rate onChange={this.handleChange} value={value} />
{value && <span className="ant-rate-text">{value} stars</span>}
</span>
);
}
}
ReactDOM.render(<Rater />, mountNode);
- AA
- AA
- AA
- AA
- AA
- 好好
- 好好
- 好好
- 好好
- 好好
import { Rate, Icon } from 'antd';
ReactDOM.render(
<div>
<Rate character={<Icon type="heart" />} allowHalf />
<br />
<Rate character="A" allowHalf style={{ fontSize: 36 }} />
<br />
<Rate character="好" allowHalf />
</div>
, mountNode);
import { Rate } from 'antd';
ReactDOM.render(<Rate allowHalf defaultValue={2.5} />, mountNode);
import { Rate } from 'antd';
ReactDOM.render(<Rate disabled defaultValue={2} />, mountNode);
API#
Property | Description | type | Default |
---|---|---|---|
allowHalf | whether to allow semi selection | boolean | false |
character | custom character of rate | ReactNode | <Icon type="star" /> |
className | custom class name of rate | string | - |
count | star count | number | 5 |
defaultValue | default value | number | 0 |
disabled | read only, unable to interact | boolean | false |
style | custom style object of rate | object | - |
value | current value | number | - |
onChange | callback when select value | Function(value: number) | - |
onHoverChange | callback when hover item | Function(value: number) | - |