Gathering detailed insights and metrics for react-native-star-rating-props-fixed
Gathering detailed insights and metrics for react-native-star-rating-props-fixed
Gathering detailed insights and metrics for react-native-star-rating-props-fixed
Gathering detailed insights and metrics for react-native-star-rating-props-fixed
npm install react-native-star-rating-props-fixed
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
4 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 10, 2024
Latest Version
1.1.1
Package Id
react-native-star-rating-props-fixed@1.1.1
Unpacked Size
1.55 MB
Size
544.90 kB
File Count
20
NPM Version
9.6.7
Node Version
18.17.0
Published on
May 10, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A React Native component for generating and displaying interactive star ratings. Compatible with both iOS and Android.
1npm install react-native-star-rating --save
or
1yarn add react-native-star-rating
react-native-vector-icons
Prop | Type | Description | Required | Default |
---|---|---|---|---|
activeOpacity | number | Number between 0 a 1 to determine the opacity of the button. | No | 0.2 |
animation | string | Add an animation to the stars when upon selection. Refer to react-native-animatable for the different animation types. | No | undefined |
buttonStyle | ViewPropTypes.style | Style of the button containing the star. | No | {} |
containerStyle | ViewPropTypes.style | Style of the element containing the star rating component. | No | {} |
disabled | bool | Sets the interactivity of the star buttons. | No | false |
emptyStar | string or image object | The name of the icon to represent an empty star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star-o |
emptyStarColor | string | Color of an empty star. | No | gray |
fullStar | string or image object | The name of the icon to represent a full star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star |
fullStarColor | string | Color of a filled star. | No | black |
halfStar | string or image object | The name of the icon to represent an half star. Refer to react-native-vector-icons. Also can be a image object, both {uri:xxx.xxx} and require('xx/xx/xx.xxx'). | No | star-half-o |
halfStarColor | string | Color of a half-filled star. Defaults to fullStarColor . | No | undefined |
halfStarEnabled | bool | Sets ability to select half stars | No | false |
iconSet | string | The name of the icon set the star image belongs to. Refer to react-native-vector-icons. | No | FontAwesome |
maxStars | number | The maximum number of stars possible. | No | 5 |
rating | number | The current rating to show. | No | 0 |
reversed | bool | Renders stars from right to left | No | false |
selectedStar | function | A function to handle star button presses. | Yes | () => {} |
starSize | number | Size of the star. | No | 40 |
starStyle | ViewPropTypes.style | Style to apply to the star. | No | {} |
For the emptyStar
, fullStar
, halfStar
, and iconSet
props, please refer to the react-native-vector-icons package for the valid string
names for the star icons. When selecting the icon string
names, you must remember to remove the font family name before the first hyphen. For example, if you want to use the ion-ios-star
from the Ionicon font set, you would set the fullStar
prop to ios-star
and the iconSet
to Ionicons
.
For the animation
prop, please refer to the react-native-animatable package for valid string
names for the different animations available.
The following example will render 3.5 stars out of 5 stars using the star-o
for the empty star icon, star-half-o
for the half star icon, and star
for the full star icon from the FontAwesome
icon set in black color.
1import StarRating from 'react-native-star-rating'; 2 3class GeneralStarExample extends Component { 4 5 constructor(props) { 6 super(props); 7 this.state = { 8 starCount: 3.5 9 }; 10 } 11 12 onStarRatingPress(rating) { 13 this.setState({ 14 starCount: rating 15 }); 16 } 17 18 render() { 19 return ( 20 <StarRating 21 disabled={false} 22 maxStars={5} 23 rating={this.state.starCount} 24 selectedStar={(rating) => this.onStarRatingPress(rating)} 25 /> 26 ); 27 } 28} 29 30export default GeneralStarExample
The following example will render 2.5 stars out of 7 stars using the ios-star-outline
for the empty star icon, ios-star-half
for the half star icon, and ios-star
for the full star icon from the Ionicons
icon set in red color.
1import StarRating from 'react-native-star-rating'; 2 3class CustomStarExample extends Component { 4 5 constructor(props) { 6 super(props); 7 this.state = { 8 starCount: 2.5 9 }; 10 } 11 12 onStarRatingPress(rating) { 13 this.setState({ 14 starCount: rating 15 }); 16 } 17 18 render() { 19 return ( 20 <StarRating 21 disabled={false} 22 emptyStar={'ios-star-outline'} 23 fullStar={'ios-star'} 24 halfStar={'ios-star-half'} 25 iconSet={'Ionicons'} 26 maxStars={7} 27 rating={this.state.starCount} 28 selectedStar={(rating) => this.onStarRatingPress(rating)} 29 fullStarColor={'red'} 30 /> 31 ); 32 } 33} 34 35export default CustomStarExample
Navigate to the root of the ExampleApp and install the dependencies
1cd ExampleApp && npm install
Run the app on the iOS simulator.
1npm run ios
Be sure to have create-react-native-app
installed.
1npm install -g create-react-native-app
Create a development app in the root folder.
1create-react-native-app DevelopmentApp
Going into the development app and clone this repo.
1cd DevelopmentApp && git clone https://github.com/djchie/react-native-star-rating.git
Go into the react-native-star-rating
directory and start developing!
1cd react-native-star-rating
View the project roadmap here
See CONTRIBUTING.md for contribution guidelines.
No vulnerabilities found.
No security vulnerabilities found.