1.8.3 • Published 1 year ago

react-native-star-svg-rating v1.8.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-star-svg-rating

npm version

A customizable, animated star rating component for React Native. Compatible with iOS, Android and Web. Written in Typescript.

Demo

Installation

  1. install react-native-star-svg-rating npm install react-native-star-svg-rating --save or yarn add react-native-star-svg-rating
  2. if not already installed, add react-native-svg

Usage

import StarRating from 'react-native-star-svg-rating';

const Example = () => {
  const [rating, setRating] = useState(0);
  return (
      <StarRating
        rating={rating}
        onChange={setRating}
      />
  );
};

Props

NameTypeDefaultDescription
ratingnumberREQUIREDRating Value. Should be between 0 and maxStars
onChange(number) => voidREQUIREDcalled when rating changes
maxStarsnumber5number of stars
starSizenumber32star size
colorstring"#fdd835"star color
borderColorstringsame as colorborder star color
emptyColorstring"#404040"empty star color
emptyBorderColorstringsame as emptyColorempty border star color
styleobjectundefinedoptional style
starStyleobjectundefinedoptional star style
enableHalfStarbooleantrueenable or disable display of half stars
enableSwipingbooleantrueenable or disable swiping
onRatingStart() => voidundefinedcalled when user starts interaction
onRatingEnd() => voidundefinedcalled when user ends interaction
animationConfigsee AnimationConfigsee AnimationConfiganimation configuration object
StarIconComponent(props: { size: number; color: string; borderColor: string; type: "full" | "half" | "empty"; }) => JSX.ElementStarIconIcon component

AnimationConfig

NameTypeDefaultDescription
scalenumber1.2star animation scale value
durationnumber300animation duration
delaynumber300animation delay when interaction has ended
easing(number) => numberEasing.elastic(2)animation easing function

A StarRatingDisplay component without any interaction functionality is exported as well.

1.8.3

1 year ago

1.8.2

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago