All Projects → voronianski → React Star Rating Component

voronianski / React Star Rating Component

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Star Rating Component

Fakescroll
vanilla-js lightweight custom HTML scrollbar
Stars: ✭ 309 (-8.31%)
Mutual labels:  component
Ngx Materialize
Angular wrap around Materialize library
Stars: ✭ 322 (-4.45%)
Mutual labels:  component
Cache
The Cache component provides an extended PSR-6 implementation for adding cache to your applications.
Stars: ✭ 3,606 (+970.03%)
Mutual labels:  component
Ngx Treeview
An Angular treeview component with checkbox
Stars: ✭ 312 (-7.42%)
Mutual labels:  component
React Component Library
A project skeleton to get your very own React Component Library up and running using Rollup, Typescript, SASS + Storybook
Stars: ✭ 313 (-7.12%)
Mutual labels:  component
Dom Crawler
The DomCrawler component eases DOM navigation for HTML and XML documents.
Stars: ✭ 3,499 (+938.28%)
Mutual labels:  component
Aframe Environment Component
🌄 Infinite background environments for A-Frame in a line of HTML.
Stars: ✭ 300 (-10.98%)
Mutual labels:  component
Vue Designer
Vue component design tool
Stars: ✭ 333 (-1.19%)
Mutual labels:  component
Vue Picture Swipe
🖼 Vue Picture Swipe Gallery (a gallery of image with thumbnails, lazy-load and swipe) backed by photoswipe
Stars: ✭ 322 (-4.45%)
Mutual labels:  component
React Music Player
🎵 Maybe the best beautiful HTML5 responsive player component for react :)
Stars: ✭ 321 (-4.75%)
Mutual labels:  component
React Querybuilder
A QueryBuilder component for React
Stars: ✭ 315 (-6.53%)
Mutual labels:  component
Security Acl
Symfony Security ACL Component
Stars: ✭ 321 (-4.75%)
Mutual labels:  component
Synedit
SynEdit main project
Stars: ✭ 324 (-3.86%)
Mutual labels:  component
Yaml
The Yaml component loads and dumps YAML files.
Stars: ✭ 3,359 (+896.74%)
Mutual labels:  component
React Virtualized Tree
A virtualized tree view component making use of react
Stars: ✭ 328 (-2.67%)
Mutual labels:  component
React Search Input
🔍 Simple react.js component for a search input, providing a filter function.
Stars: ✭ 300 (-10.98%)
Mutual labels:  component
Polyfill Php70
This component provides features unavailable in releases prior to PHP 7.0.
Stars: ✭ 3,270 (+870.33%)
Mutual labels:  component
Dependency Injection
The DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.
Stars: ✭ 3,635 (+978.64%)
Mutual labels:  component
Config
The Config component helps you find, load, combine, autofill and validate configuration values of any kind, whatever their source may be (YAML, XML, INI files, or for instance a database).
Stars: ✭ 3,671 (+989.32%)
Mutual labels:  component
Vue.isotope
📱 Vue component for isotope filter & sort magical layouts
Stars: ✭ 326 (-3.26%)
Mutual labels:  component

react-star-rating-component

npm version Dependency Status Download Count

Tiny React.js component for star (or any other icon based) ratings.

Install

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

Demo

Props

<StarRatingComponent
    name={String} /* name of the radio input, it is required */
    value={Number} /* number of selected icon (`0` - none, `1` - first) */
    starCount={Number} /* number of icons in rating, default `5` */
    onStarClick={Function(nextValue, prevValue, name)} /* on icon click handler */
    onStarHover={Function(nextValue, prevValue, name)} /* on icon hover handler */
    onStarHoverOut={Function(nextValue, prevValue, name)} /* on icon hover out handler */
    renderStarIcon={Function(nextValue, prevValue, name)} /* it should return string or react component */
    renderStarIconHalf={Function(nextValue, prevValue, name)} /* it should return string or react component */
    starColor={String} /* color of selected icons, default `#ffb400` */
    emptyStarColor={String} /* color of non-selected icons, default `#333` */
    editing={Boolean} /* is component available for editing, default `true` */
/>

Examples

Editable

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 (                
      <div>
        <h2>Rating from state: {rating}</h2>
        <StarRatingComponent 
          name="rate1" 
          starCount={10}
          value={rating}
          onStarClick={this.onStarClick.bind(this)}
        />
      </div>
    );
  }
}

ReactDOM.render(
  <App />, 
  document.getElementById('app')
);

Non-editable (with custom icons)

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 (                
      <div>
        <h2>Rating from state: {rating}</h2>
        <StarRatingComponent 
          name="rate2" 
          editing={false}
          renderStarIcon={() => <span></span>}
          starCount={10}
          value={8}
        />
      </div>
    );
  }
}

ReactDOM.render(
  <App />, 
  document.getElementById('app')
);

Check more in examples folder.


MIT Licensed

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].