0.2.2 • Published 2 years ago

rc-ratings v0.2.2

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

React Ratings

React Ratings is a React rating component built with StyledComponents 💅

Installation

You can install rc-ratings component using the yarn or npm package manager:

yarn add rc-ratings
npm install rc-ratings

Dependencies

The rc-ratings component peer depends on the React library.

You can install React using yarn:

yarn add --save react react-dom

Usage

Import Rating Component

import Rating from "rc-ratings";

Start using it:

<Rating />

Pass some config props:

<Rating animateOnHover disableAnimation initialRate={3} stop={10} />

Properties

PropertyTypeDefaultDescription
animateOnHoverBooleanfalseWhether to animate rate hovering or not.
disableAnimationBooleanfalseDisable stars animation onClick or onHover.
emptyRateReact ElementEmpty StarReact Element
fractionsNumber1Number of equal parts that make up a whole symbol.
fullRateReact ElementFull StarReact element
initialRateNumber0Initial rate value.
readonlyBooleanfalseWhether the rating can be modified or not.
startNumber0Range starting value.
stepNumber1Step increment (must be between start and stop).
stopNumber5Range stop value.

Callbacks

CallbackTypeParametersDescription
onChangeFunctionrate: NumberCalled when the selected rate is changed.
onClickFunction(rate: Number, event: Event)Called when a rate is clicked.
onRateFunctionrate: Number or undefinedCalled when a rate is entered or left. When a rate is left it is called with undefined.