# react-star-rating

> A simple star rating component built with React.

Latest version **1.4.2** (published 2015-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-star-rating
pnpm add react-star-rating
yarn add react-star-rating
bun add react-star-rating
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.2 |
| Published | 2015-11-08 |
| First published | 2015-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cameron J Roe |
| Maintainers | cameronjroe |

## Links

- npm: https://www.npmjs.com/package/react-star-rating
- npm.io page: https://npm.io/package/react-star-rating

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^0.14.2
- [react-dom](https://npm.io/package/react-dom.md) ^0.14.2
- [classnames](https://npm.io/package/classnames.md) ^2.2.0
- [react-addons-test-utils](https://npm.io/package/react-addons-test-utils.md) ^0.14.2

## Recent versions

- 1.4.2 (latest) — 2015-11-08
- 1.4.1 — 2015-11-08
- 1.4.0 — 2015-11-08
- 1.3.2 — 2015-07-21
- 1.3.1 — 2015-06-26
- 1.3.0 — 2015-06-26
- 1.2.0 — 2015-06-13
- 1.1.4 — 2015-03-14
- 1.1.3 — 2015-03-14
- 1.1.0 — 2015-03-09
- 1.0.0 — 2015-03-08

## README

# react-star-rating ![](https://david-dm.org/cameronjroe/react-star-rating.svg)

[![NPM](https://nodei.co/npm/react-star-rating.png?compact=true)](https://nodei.co/npm/react-star-rating/)

<!-- [![Build Status](https://travis-ci.org/)](https://travis-ci.org/) -->
![](src/assets/star-rating.png)

> A simple star rating component built with React.

## v1.4.0 coming soon.

## Install

```sh
$ npm install react-star-rating --save
```
## Usage

### ES6
```js
import React from 'react';
import StarRating from 'react-star-rating';

class FormComponent extends React.Component {
  render() {
    return (
      <form action="/api" method="POST">
        <StarRating name="airbnb-rating" caption="Rate your stay!" ratingAmount={5} />
        <button type="submit" className="btn btn-submit">Submit Rating</button>
      </form>
    );
  }
}

React.render(<FormComponent />, document.getElementById('star-rating'));
```

### ES5
```js
var React = require('react');
var StarRating = require('react-star-rating');

var FormComponent = React.createClass({
    render: function () {
      return (
        <form action="/api" method="POST">
          <StarRating name="airbnb-rating" caption="Rate your stay!" ratingAmount={5} />
          <button type="submit" className="btn btn-submit">Submit Rating</button>
        </form>
      );
    }
});

React.render(<FormComponent />, document.getElementById('star-rating'));
```

## Options
  - **name**={string} - name for form input (required)
  - **caption**={string} - caption for rating (optional)
  - **totalStars**={number} - rating amount (required, default: 5)
  - **rating**={number} - a set rating between the rating amount (optional)
  - **disabled**={boolean} - whether to disable the rating from being selected (optional)
  - **editing**={boolean} - whether the rating is explicitly in editing mode (optional)
  - **size**={number} - size of stars (optional)
  - **onRatingClick**={function} - a handler function that gets called onClick of the rating (optional) - gets passed (event, {position, rating, caption, name})

## Todo

- [x] Fix ES6 bug with bundling
- [x] Add svg stars
- [x] Double-check touch support works
- [ ] Re-implement star hovering (kinda janky right now)


## License

[MIT](https://github.com/cameronjroe/react-star-rating/blob/master/LICENSE)

---
_Source: https://npm.io/package/react-star-rating · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
