Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/voronianski/react-star-rating-component

Basic React component for star (or any other icon based) rating elements
https://github.com/voronianski/react-star-rating-component

component react star-ratings

Last synced: 4 days ago
JSON representation

Basic React component for star (or any other icon based) rating elements

Awesome Lists containing this project

README

        

# react-star-rating-component

[![npm version](http://badge.fury.io/js/react-star-rating-component.svg)](http://badge.fury.io/js/react-star-rating-component)
[![Dependency Status](http://david-dm.org/voronianski/react-star-rating-component.svg)](http://david-dm.org/voronianski/react-star-rating-component)
[![Download Count](http://img.shields.io/npm/dm/react-star-rating-component.svg?style=flat)](http://www.npmjs.com/package/react-star-rating-component)

> Tiny [React.js](https://facebook.github.io/react) component for star (or any other *icon based*) ratings.

## Install

```bash
npm install react-star-rating-component --save
```

## Demo

[](http://voronianski.github.io/react-star-rating-component/example)

## Props

```javascript

```

## Examples

### Editable

```javascript
import React from 'react';
import ReactDOM from 'react-dom';
import StarRatingComponent from 'react-star-rating-component';

class App extends React.Component {
constructor() {
super();

this.state = {
rating: 1
};
}

onStarClick(nextValue, prevValue, name) {
this.setState({rating: nextValue});
}

render() {
const { rating } = this.state;

return (


Rating from state: {rating}




);
}
}

ReactDOM.render(
,
document.getElementById('app')
);
```

### Non-editable (with custom icons)

```javascript
import React from 'react';
import ReactDOM from 'react-dom';
import StarRatingComponent from 'react-star-rating-component';

class App extends React.Component {
render() {
const { rating } = this.state;

return (


Rating from state: {rating}


}
starCount={10}
value={8}
/>

);
}
}

ReactDOM.render(
,
document.getElementById('app')
);
```

Check more in [examples folder](https://github.com/voronianski/react-star-rating-component/tree/master/example).

---

**MIT Licensed**