# @rc-component/rate

> React Star Rate Component

Latest version **1.0.1** (published 2025-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rc-component/rate
pnpm add @rc-component/rate
yarn add @rc-component/rate
bun add @rc-component/rate
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2025-11-28 |
| First published | 2025-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8.x |
| Dependencies | 2 |
| Unpacked size | 33.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 98 |
| Maintainers | zombiej, afc163, madccc, peachscript, chenshuai2144 |
| Keywords | react, react-component, react-rate, rate |

## Links

- npm: https://www.npmjs.com/package/@rc-component/rate
- Repository: https://github.com/react-component/rate
- Issues: https://github.com/react-component/rate/issues
- npm.io page: https://npm.io/package/@rc-component/rate

## Dependencies (2)

- [clsx](https://npm.io/package/clsx.md) ^2.1.1
- [@rc-component/util](https://npm.io/package/@rc-component/util.md) ^1.3.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2025-11-28
- 1.0.0 — 2025-09-16

## README

# rc-rate

React Rate Component

[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]
[![build status][github-actions-image]][github-actions-url]
[![Codecov][codecov-image]][codecov-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[![dumi][dumi-image]][dumi-url]

[npm-image]: http://img.shields.io/npm/v/rc-rate.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-rate
[github-actions-image]: https://github.com/react-component/rate/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/rate/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/rate/master.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/react-component/rate/branch/master
[david-url]: https://david-dm.org/react-component/rate
[david-image]: https://david-dm.org/react-component/rate/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/rate?type=dev
[david-dev-image]: https://david-dm.org/react-component/rate/dev-status.svg?style=flat-square
[download-image]: https://img.shields.io/npm/dm/rc-rate.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-rate
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-rate
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-rate
[dumi-url]: https://github.com/umijs/dumi
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square

## Screenshots

<img src="https://img.alicdn.com/tps/TB1ijlpLVXXXXb8XpXXXXXXXXXX-466-172.png" width="288"/>

## Changelog

- [CHANGELOG](./CHANGELOG.md)

## Development

```
npm install
npm start
```

## Example

- Local: http://localhost:9001/

- Online: http://react-component.github.io/rate/

## install

[![rc-rate](https://nodei.co/npm/rc-rate.png)](https://npmjs.org/package/rc-rate)

## Usage

```js
import React from 'react';
import ReactDOM from 'react-dom';
import Rate from '@rc-component/rate';

ReactDOM.render(
  <Rate />,
  document.getElementById('root')
)
```

### with [styled-components](https://github.com/styled-components/styled-components)
```js
import React from 'react';
import ReactDOM from 'react-dom';
import Rate from '@rc-component/rate';
import styled from 'styled-components';

const StyledRate = styled(Rate)`
  &.rc-rate {
    font-size: ${({ size }) => size}px;
  }
`

ReactDOM.render(
  <StyledRate size="24" />,
  document.getElementById('root')
)
```

## API

### props

| name          | type                              | default       | description                                           |
| ------------- | --------------------------------- | ------------- | ----------------------------------------------------- |
| count         | number                            | 5             | Star numbers                                          |
| value         | number                            | -             | Controlled value                                      |
| defaultValue  | number                            | 0             | Initial value                                         |
| allowHalf     | boolean                           | false         | Support half star                                     |
| allowClear    | boolean                           | true          | Reset when click again                                |
| style         | object                            | {}            |                                                       |
| onChange      | function                          | (value) => {} | `onChange` will be triggered when click               |
| onHoverChange | function                          | (value) => {} | `onHoverChange` will be triggered when hover on stars |
| character     | ReactNode \| (props) => ReactNode | ★             | The each character of rate                            |
| disabled      | boolean                           | false         |                                                       |
| direction     | string                            | `ltr`         | The direction of rate                                 |

## Test Case

```
npm test
npm run chrome-test
```

## Coverage

```
npm run coverage
```

open coverage/ dir

## License

rc-rate is released under the MIT license.

---
_Source: https://npm.io/package/@rc-component/rate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
