• Stars
    star
    862
  • Rank 52,908 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 8 months ago

Reviews

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

Repository Details

Tap and Swipe Ratings component for React Native.

react-native-ratings

Ratings component for React Native with tap and swipe enabled.

Demo - try it now

Demo gif

Tap Rating

Swipe Rating

Installation

Install the package using yarn or npm:

yarn add react-native-ratings

OR

npm install --save react-native-ratings

Usage

import { Rating, AirbnbRating } from 'react-native-ratings';

const WATER_IMAGE = require('./water.png')

ratingCompleted(rating) {
  console.log("Rating is: " + rating)
}

<AirbnbRating />

<AirbnbRating
  count={11}
  reviews={["Terrible", "Bad", "Meh", "OK", "Good", "Hmm...", "Very Good", "Wow", "Amazing", "Unbelievable", "Jesus"]}
  defaultRating={11}
  size={20}
/>

<Rating
  showRating
  onFinishRating={this.ratingCompleted}
  style={{ paddingVertical: 10 }}
/>

<Rating
  type='heart'
  ratingCount={3}
  imageSize={60}
  showRating
  onFinishRating={this.ratingCompleted}
/>

<Rating
  type='custom'
  ratingImage={WATER_IMAGE}
  ratingColor='#3498db'
  ratingBackgroundColor='#c8c7c8'
  ratingCount={10}
  imageSize={30}
  onFinishRating={this.ratingCompleted}
  style={{ paddingVertical: 10 }}
/>

Also refer to the example app for more detailed usage example.

API

AirbnbRating

prop default type description
defaultRating 3 number Initial value for the rating
reviews ['Terrible', 'Bad', 'Okay', 'Good', 'Great'] string[] Labels to show when each value is tapped e.g. If the first star is tapped, then value in index 0 will be used as the label
count 5 number Total number of ratings to display
selectedColor #f1c40f string (color) Pass in a custom fill-color for the rating icon
unSelectedColor #BDC3C7 string (color) Pass in a custom not fill-color for the rating icon
reviewColor #f1c40f string (color) Pass in a custom text color for the review text
size 40 number The size of each rating image (optional)
reviewSize 25 number Pass in a custom font size for the review text
showRating true boolean Determines if to show the reviews above the rating
isDisabled false boolean Whether the rating can be modiefied by the user
onFinishRating none function(value: number) Callback method when the user finishes rating. Gives you the final rating value as a whole number
starContainerStyle none object or stylesheet Custom styles applied to the star container
ratingContainerStyle none object or stylesheet Custom styles applied to the rating container
starImage STAR_IMAGE string Pass in a custom base image source (optional)

RatingProps

prop default type description
type star string Choose one of the built-in types: star, rocket, bell, heart or use type custom to render a custom image (optional)
ratingImage star string Pass in a custom image source; use this along with type='custom' prop above (optional)
ratingColor #f1c40f string (color) Pass in a custom fill-color for the rating icon; use this along with type='custom' prop above (optional)
ratingBackgroundColor white string (color) Pass in a custom background-fill-color for the rating icon; use this along with type='custom' prop above (optional)
tintColor none string Color used to change the background of the rating icon (optional)
ratingCount 5 number The number of rating images to display (optional)
ratingTextColor none string Color used for the text labels
imageSize 50 number The size of each rating image (optional)
showRating none boolean Displays the Built-in Rating UI to show the rating value in real-time (optional)
readonly false boolean Whether the rating can be modiefied by the user
startingValue ratingCount/2 number The initial rating to render
fractions 2 number The number of decimal places for the rating value; must be between 0 and 20
minValue 0 number The minimum value the user can select
style none style Exposes style prop to add additonal styling to the container view (optional)
jumpValue 0 number The value to jump when rating value changes (if jumpValue === 0.5, rating value increases/decreases like 0, 0.5, 1.0, 1.5 ...). Default is 0 (not to jump)
onStartRating none function(rating: number) Callback method when the user starts rating. Gives you the start rating value as a whole number
onSwipeRating none function(rating: number) Callback method when the user is swiping. Gives you the current rating value as a whole number
onFinishRating none function(rating: number) Callback method when the user finishes rating. Gives you the final rating value as a whole number (required)

Try it out

You can try it out with Expo here. Or you can also run the example app locally.

Motivation

One of my friends showed me this Star Rating feature in Bootstrap and it looks really interesting. So I challenged myself to re-implement it in React Native.

Followed by that, for v3, I recreated the Airbnb ratings component and added it to this repo, in case others find this useful. It works out of the box and is quite functional.

Also this is my first npm module 🎊

Feedback

This repo is being actively manitained. Feel free to open a new Issue with a Feature Request or submit a PR with an Enhancement.

More Repositories

1

react-native-parallax-scrollview

The Parallax ScrollView component we all deserve. 🚀
JavaScript
279
star
2

react-native-starter

🚀 Starter app for your React Native project using all the latest 💯 & greatest 🏅 components!
JavaScript
84
star
3

react-native-social-starter

React Native Social Starter app - Uses Twitter & Facebook login + Displays User Feed & Profile views
Objective-C
30
star
4

react-native-tinder-cards

Implementing Tinder Card animations in React Native
JavaScript
28
star
5

react-native-graphql-todolist

Todo list app = React Native + Expo + GraphQL + Apollo
JavaScript
17
star
6

Start-Developing-iOS-Apps-Today

This repo provides the perfect starting point for iOS development in Obj-C (and Swift).
Objective-C
12
star
7

Uber-ReactNative

Uber map view with animation built using React Native
JavaScript
9
star
8

HelloWorld-Blockchain

Hello World Dapp in Ethereum with Solidity
JavaScript
4
star
9

Cards-Against-Humanity

Built for CSC 667- Cards against humanity game using Ruby on rails.
Ruby
4
star
10

Asphalt

Functional React Native App; to push the boundaries of my RN skills
JavaScript
4
star
11

xandar

Upload an image and Xandar will predict whether it's a cat or a dog.
JavaScript
4
star
12

portfolio-website

Monte Thakkar - Portfolio Website
JavaScript
3
star
13

reactxp-instagram

Instagram clone built using react-xp. Runs on iOS/Android & Web.
Makefile
3
star
14

todo-list

To-do list app - iOS 11 & Swift 4
Swift
3
star
15

Trump-Quotes-API

Repo that provides Trump Quotes through a simple API.
Ruby
3
star
16

Reddit-ReactNative

Reddit Client app using React Native
Java
3
star
17

parkmerced.live

19th Ave & Karl The Fog - SF Live Stream
CSS
3
star
18

naturexplorer

A website for viewing amazing nature images from various Reddit subs
JavaScript
3
star
19

HelloWorld-Go

Hello world program in Go(lang)
Go
3
star
20

nextjs-tailwindcss-chatgpt-clone

A fully functional clone of ChatGPT website w/ OpenAI API
TypeScript
2
star
21

shitty-instagram

Shitty Instagram close built using React Native
JavaScript
2
star
22

freEDU-Mobile

Mobile App for freEdu: Free Tech Education https://freedu.tech/
JavaScript
2
star
23

Emoji-Artbook

An iOS app for artist to create art with emoji's and images.
Swift
2
star
24

Listenn

Listnn is a iOS app that turns your iPhone into a audio travel guide as you explore the city.
Swift
2
star
25

android-react-native-app

Android app integrated with React Native
Java
2
star
26

MorseCode

Morse Code player for the web
JavaScript
1
star
27

iOS-portfolio-outdated

This is a portfolio of all my work in iOS development.
1
star
28

chantal-app

Chantal - Share stories, anonymously!
JavaScript
1
star
29

pillowcoin

Pillow's own cryptocurrency
JavaScript
1
star
30

portfolio-website-v1

Monte Thakkar - Portfolio website v1
JavaScript
1
star
31

draper

YC Hacks - 2018
JavaScript
1
star
32

TodoApp-Android

Pre-work for Android bootcamp at @Uber x @CodePath
Java
1
star
33

TrumpedOut

Built at Hacktech 2016- Prompt bot wirtten in Node.js + jquery
JavaScript
1
star
34

YelpApp-CodePathU

YelpM is a Yelp search app using the Yelp API.
Swift
1
star
35

SlackTeam-iOSApp

iOS App to view Slack teams
C++
1
star
36

Foto-CodePathU

iOS App for CodePath Demo Day- Converts collection of images into a video for easy sharing.
Objective-C
1
star
37

MovieGuide-ReactNative

Movie Guide app using React Native
JavaScript
1
star
38

nextjs-starter-template

Started template for Next.js + TailwindCSS + NextThemes
JavaScript
1
star
39

react-native-auth

Implementing One Time Password using Text Messages in React Native
HTML
1
star
40

typps

tyypps is a Tip Calculator + Restaurant Logger app for iOS
C++
1
star