2.0.5 • Published 4 years ago

react-rating v2.0.5

Weekly downloads
38,282
License
MIT
Repository
github
Last release
4 years ago

npm version

React Rating

React Rating is a react rating component which supports custom symbols both with inline styles and glyphicons found in popular CSS Toolkits like Fontawesome or Bootstrap.

This React component was inspired by the jQuery plugin bootstrap-rating.

Demo

See react-rating in action.

Installation

You can install react-rating component using the npm package manager:

npm install --save react-rating

Dependencies

The react-rating component peer depends on the React library.

You can install React using npm too:

npm install --save react

Upgrade Warning

If you are using a version of React Rating < v1.0 be aware that there are API changes between anything < v1.0 and v1.0 . See the Properties and Deprecated Properties and Callbacks sections below for a documentation of the current API and how it compares to the old.

Usage

  1. Require the Rating Component

    var Rating = require('react-rating');
  2. Start using it

    With raw javascript:

    React.createElement(Rating)

    Or with JSX:

    <Rating />

Properties

PropertyTypeDefaultDescription
startnumber0Range starting value (exclusive).
stopnumber5Range stop value (inclusive).
stepnumber1Describes how many values each Symbol represents. For example, for a start value of 0, a stop value of 10 and a step of 2, we will end up with 5 Symbols, with each Symbol representing value increments of 2.
fractionsnumber1Number of equal subdivisions that can be selected as a rating in each Symbol. For example, for a fractions value of 2, you will be able to select a rating with a precision of down to half a Symbol. Must be >= 1
initialRatingnumber0The value that will be used as an initial rating. This is the old initialRate.
placeholderRatingnumber0If you do not define an initialRating value, you can use a placeholder rating. Visually, this will have the same result as if you had defined an initialRating value. If initialRating is set placeholderRating is not taken into account. This is the old placeholderRate
readonlyboolfalseWhether the rating can be modified or not.
quietboolfalseWhether to animate rate hovering or not.
directionltr or rtlltrThe direction of the rating element contents
emptySymbolelement or object or string or arrayStyle.emptyReact element, inline style object, or classes applied to the rating symbols when empty. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old empty.
fullSymbolelement or object or string or arrayStyle.fullReact element, inline style object, or classes applied to the rating symbols when full. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old full.
placeholderSymbolelement or object or string or arrayStyle.placeholderReact element, inline style object, or classes applied to the placeholder rating symbols. Can also be an array of such symbols that will be applied in a circular manner (round-robin). This is the old placeholder.

Callbacks

CallbackTypeDescription
onChangefunction (value) {}Gets called with the value when a different value than the currently set is selected.
onClickfunction (value) {}Gets called with the value when a symbol is clicked. The value is equal to the value that corresponds to that part of the symbol.
onHoverfunction (value) {}Gets called with the value when you hover over a symbol. The value is equal to the value that corresponds to that part of the symbol. Gets called in quiet mode too. When hover ends, gets called with no value (i.e. undefined as the value).

Deprecated Properties and Callbacks

This is a list of deprecated properties and callbacks from versions older than v1.0

  • onRate
  • initialRate
  • placeholderRate
  • empty
  • full
  • placeholder

License

MIT License

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.9.1

6 years ago

0.9.0

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago