• Stars
    star
    173
  • Rank 220,124 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Looking for Maintainers (email me)]: A simple star rating component built with React.

react-star-rating

NPM

A simple star rating component built with React.

Install

$ npm install react-star-rating --save

Include the css:

<link rel="stylesheet" href="node_modules/react-star-rating/dist/css/react-star-rating.min.css">

Usage

ES6

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!" totalStars={5} />
        <button type="submit" className="btn btn-submit">Submit Rating</button>
      </form>
    );
  }
}

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

ES5

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!" totalStars={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

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

License

MIT

More Repositories

1

awesome-marketing

A curated list of resources related to internet marketing.
205
star
2

bootstrap-itscss

ITCSS port of Bootstrap SASS
CSS
33
star
3

metalpress

Create a blog easily with Metalsmith.
JavaScript
17
star
4

angular-movie-search

Angular Movie Search
CSS
15
star
5

jquery-flipper

CSS3 card flip effect.
JavaScript
15
star
6

awesome-firebase

A curated list of resources related to firebase.
8
star
7

awesome-webrtc

A curated list of awesome WebRTC modules and resources.
6
star
8

http-status-codes

Search HTTP status codes - written with React, Flux, ES6, Browserify
JavaScript
4
star
9

lightpack

⚡️ Quick tool for webpack. Call a function and get to the real work...
JavaScript
3
star
10

metalsmith-firebase

Load firebase data into metalsmith.
JavaScript
3
star
11

metalpress-cli

CLI for Metalpress (Official)
JavaScript
2
star
12

metalsmith-blog

A simple blog demonstrating using metalsmith with both the CLI and JS API.
HTML
2
star
13

sync

A step drum machine built with web audio. (v2 coming soon...)
JavaScript
2
star
14

metalsmith-boilerplate

An opinionated boilerplate for using Metalsmith.
JavaScript
1
star
15

3d-css3-cube

A 3D cube built with SASS.
CSS
1
star
16

image-share-app

JavaScript
1
star
17

generator-simple-template

A Yeoman generator for simple web templates.
JavaScript
1
star
18

weather

Make more stuff..
JavaScript
1
star
19

six-sigma

Six Sigma research and experiments.
1
star
20

cube-rotation

JavaScript
1
star
21

react-boilerplate

A boilerplate for building react components.
JavaScript
1
star
22

tensorflow-content

Exploring TensorFlow and Content Models (Mastermind)
1
star
23

react-reviews-app

A reviews app in React.
CSS
1
star
24

next-demo

Demo app to explore next.
JavaScript
1
star
25

ninja-algorithms

JavaScript
1
star
26

khaos-html

A Khaos template for html templates.
JavaScript
1
star
27

kosmos

(WIP)
JavaScript
1
star