react-star-ratings vs react-rating-stars-component vs react-star-rating-component
React Star Rating Components Comparison
1 Year
react-star-ratingsreact-rating-stars-componentreact-star-rating-componentSimilar Packages:
What's React Star Rating Components?

Star rating components are essential UI elements used to gather user feedback through a visual representation of ratings, typically in the form of stars. These components enhance user experience by allowing quick and intuitive input of ratings for products, services, or content. The three packages listed provide various functionalities and customization options, catering to different project requirements and developer preferences.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-star-ratings37,277153-447 years agoBSD-3-Clause
react-rating-stars-component16,41571-175 years agoISC
react-star-rating-component10,69237970.5 kB25-MIT
Feature Comparison: react-star-ratings vs react-rating-stars-component vs react-star-rating-component

Customization

  • react-star-ratings:

    Provides moderate customization options, allowing developers to set the number of stars and colors. However, it does not support half-star ratings, which may limit its use in certain scenarios.

  • react-rating-stars-component:

    This package offers extensive customization options, allowing developers to change the number of stars, colors, and sizes. It also supports half-star ratings, which can enhance user feedback accuracy.

  • react-star-rating-component:

    Customization is limited compared to others, focusing on basic star configurations. It allows for some styling but lacks advanced features like half-star ratings, making it less flexible for unique designs.

Ease of Use

  • react-star-ratings:

    This package has a slightly steeper learning curve due to its more advanced features, but it is still user-friendly for developers familiar with React.

  • react-rating-stars-component:

    This package is designed for ease of use, with a simple API that allows for quick integration into any React project. The documentation is clear and provides examples for various use cases.

  • react-star-rating-component:

    The API is straightforward, making it easy for developers to implement. However, its simplicity may limit its functionality for more complex requirements.

Performance

  • react-star-ratings:

    Designed with performance in mind, it efficiently manages state and updates, making it suitable for applications that require handling many ratings.

  • react-rating-stars-component:

    Optimized for performance, this package minimizes re-renders and efficiently handles user interactions, making it suitable for applications with high user engagement.

  • react-star-rating-component:

    Performance is adequate for small applications, but it may struggle with larger datasets or frequent updates due to its simplicity.

Community Support

  • react-star-ratings:

    Benefits from a moderate level of community support, with sufficient resources available for troubleshooting and implementation.

  • react-rating-stars-component:

    Has a growing community and active maintenance, ensuring that developers can find support and updates regularly.

  • react-star-rating-component:

    This package has a smaller community, which may result in limited support and fewer updates over time.

Documentation

  • react-star-ratings:

    Offers decent documentation, but it may not be as extensive as that of the other packages, potentially making it harder for beginners to get started.

  • react-rating-stars-component:

    Comprehensive documentation with examples and use cases, making it easy for developers to understand and implement the component effectively.

  • react-star-rating-component:

    Documentation is basic and may lack detailed examples, which could hinder new users from fully utilizing its capabilities.

How to Choose: react-star-ratings vs react-rating-stars-component vs react-star-rating-component
  • react-star-ratings:

    Opt for this package if you require a robust solution that supports both controlled and uncontrolled components, along with a focus on performance. It is a good choice for applications that need to handle a large number of ratings efficiently.

  • react-rating-stars-component:

    Choose this package if you need a highly customizable star rating component that supports half-star ratings and allows for easy styling through CSS. It is ideal for projects where visual appearance and user interaction are paramount.

  • react-star-rating-component:

    Select this package if you are looking for a straightforward and lightweight solution with basic star rating functionality. It is suitable for simple applications where minimal features are needed without extensive customization.

README for react-star-ratings

React Star Ratings

Customizable react star ratings. SVG stars that show aggregate star ratings to the hundreths decimal point.

Install

npm install --save react-star-ratings

Heads up

I made a better version (in my opinion at least) of this repo right here: react-ratings-declarative

It is a lot more extendable and customizable.

Demo

codepen playground of similar project

Demo Example Image

Usage

import StarRatings from './react-star-ratings';

class Foo extends Component {
    changeRating( newRating, name ) {
      this.setState({
        rating: newRating
      });
    }

    render() {
      // rating = 2;
      return (
        <StarRatings
          rating={this.state.rating}
          starRatedColor="blue"
          changeRating={this.changeRating}
          numberOfStars={6}
          name='rating'
        />
      );
    }
}


class Bar extends Component {
  render() {
    // aggregateRating = 2.35;
    return (
      <StarRatings
        rating={2.403}
        starDimension="40px"
        starSpacing="15px"
      />
    );
  }
}

API v2

| Prop | Type | Default | Description | Example | | ---- | ---- | ------- | ----------- | ------- | | rating | number | 0 | The user's rating. Number of stars to highlight. | 3 | | numberOfStars | number | 5 | The max number of stars to choose from or to display | 6 | | changeRating | function | ()=>{} | Callback that will be passed the new rating a user selects | const setNewRating = (rating) => this.props.dispatch( fooActions.setRating(rating) ) | | starRatedColor | string | 'rgb(109, 122, 130)' | Color of stars that the user has rated | black | | starEmptyColor | string | 'rgb(203, 211, 227)' | Color of stars that the use hasn't rated | grey | | starHoverColor | string | 'rgb(230, 67, 47)' | Color of star when hovering over it in selection mode | yellow | | starDimension | string | '50px' | The width and height of the star | 15px | | starSpacing | string | '7px' | The spacing between the stars | 0 | | gradientPathName | string | '' | gradientPathname needed if app's path is not at the root | /app/ | | ignoreInlineStyles | boolean | false | ignore all the inline styles and write your own css using the provided classes | true | | svgIconPath | string | 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' | Set a path that describes the svg shape | 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' | | svgIconViewBox | string | '0 0 51 48' | Set the view box for a custom svg path you might have | '0 0 51 48' | | name | string | '' | Component's unique identification. Can be used when more than one star rating components are used | 'rating' |

API v1

| Prop | Type | Default | Description | Example | | ---- | ---- | ------- | ----------- | ------- | | rating | number | 0 | The user's rating. Number of stars to highlight. | 3 | | numOfStars | number | 5 | The max number of stars to choose from or to display | 6 | | changeRating | function | ()=>{} | Callback that will be passed the new rating a user selects | const setNewRating = (rating) => this.props.dispatch( fooActions.setRating(rating) ) | | isSelectable | boolean | false | Determines whether user can select a new rating or whether the stars are just for display | true | | isAggregateRating | boolean | true | Determines whether stars' will show a fraction of a star (.5 stars) | false | | starSelectingHoverColor | string | 'rgb(230, 67, 47)' | Color of star when hovering over it in selection mode | yellow | | starRatedColor | string | 'rgb(109, 122, 130)' | Color of stars that the user has rated | black | | starEmptyColor | string | 'rgb(203, 211, 227)' | Color of stars that the use hasn't rated | grey | | starWidthAndHeight | string | '50px' | The width and height of the star | 15px | | starSpacing | string | '7px' | The spacing between the stars | 0 | | gradientPathName | string | '' | gradientPathname needed if app's path is not at the root | /app/ | | ignoreInlineStyles | boolean | false | ignore all the inline styles and write your own css using the provided classes | true | | svgIconPath | string | 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' | Set a path that describes the svg shape | 'm25,1 6,17h18l-14,11 5,17-15-10-15,10 5-17-14-11h18z' | | svgIconViewBox | string | '0 0 51 48' | Set the view box for a custom svg path you might have | '0 0 51 48' |

Browser Support

Supports Chrome, firefox, safari, edge, and ie 9+. The star is SVG, so this library fails for any browser that doesn't support svg.

Potential Gradient Path Name Issue

I use the css property fill: 'url(#starGrad<randomNum>)'; to fill in just a percentage of a star. It has some weird bugs depending on the pathname of the app. Normally SPA's have window.location.pathname === '/', but if you append window.location.origin with the pathname of say app, so that window.location.pathname === '/app/', then you need a gradientPathName of '/app/'.

Here is a stackoverflow post that I found that was related to this issue: http://stackoverflow.com/questions/36774188/svg-internal-url-links-and-iframes-on-wirecloud

Try Example And Contribute

To try out the example in this repo: First clone this repo. And then using a complicated build set up stolen from TJ you run make start and go to port 5000. I actually used a forked version of that with slight changes that makes it easier to build multiple files. The only change I made pertains to how the babel cli is used

If you want to contribute: Make changes in the src folder. And then run make build. And of course test by running make start. The make build command compiles react and es6 stuff using babel from src/ into build/. (make start currently broken. instead cd in test folder and run npm run start)