ā React Native stock star rating component with zero dependencies
npm install react-native-stock-star-rating| | | | | |
| --------------------------------------- | -------- | ---------- |---------- |---------- |
| !NPM VERSION | !NPM WEEKLY DOWNLOADS | !GITHUB STAR | !YOUTUBE VIEWS | !NPM LIFETIME DOWNLOADS
sh
$ npm install react-native-stock-star-rating
`
OR
`sh
$ yarn add react-native-stock-star-rating
`
š Displaying the rating
`jsx
import { Rating } from 'react-native-stock-star-rating'
const App = () => {
return(
)
};
`
src="https://i.imgur.com/8YIvDsN.gif"
title="Star rating demo"
>
Star Rating Demo
For Live Demo (Expo Snack)
ā Props for rating
| Name | Type | Description | Default |
| ---- | ---- | ----------- | ----------- |
| maxStars | Number | Number of stars to show (Optional) | 5
| stars | Number | Filled stars to show or value of rating | 0
| size | Number | Size of the star (Optional) | 25
| color | String | Use the color you want to give to the rating stars (Optional) | #FFDF00
| bordered | boolean | Set to true if you want bordered stars (Optional) | false
š Star Rating Input
If you want to provide star rating input to capture the rating given by users, you can use this as below:
`jsx
import { RatingInput } from 'react-native-stock-star-rating'
const App = () => {
const [rating,setRating] = React.useState(0);
return(
rating={rating}
setRating={setRating}
size={50}
maxStars={5}
bordered={false}
/>
)
};
`
src="https://i.imgur.com/SH24cVd.gif"
title="Star rating input demo"
>
Star Rating Input Demo
ā Props for rating input
| Name | Type | Description | Default |
| ---- | ---- | ----------- | ----------- |
| rating | Number | State variable to store the rating (Required) | 0
| setRating | Function | Function to update the rating state variable (Required) | -
| maxStars | Number | Number of stars to show (Optional) | 5
| stars | Number | Filled stars to show or value of rating | 0
| size | Number | Size of the star (Optional) | 25
| color | String | Use the color you want to give to the rating stars (Optional) | #FFDF00
| bordered | boolean | Set to true if you want bordered stars (Optional) | false
| onRating | Function | Callback function to execute after rating input is given (Optional) | -
ā¶ļø Watch Tutorial Video

For Live Demo` (Expo Snack)