Skip to main content

StarRating

The StarRating component in our library is a user-friendly interface element used to collect ratings from users. It typically presents a series of stars that users can click or tap to indicate their rating preference, ranging from one star (lowest) to five stars (highest). Star ratings are commonly used in various applications and websites to gather feedback on products, services, or content.

Usage

Basic usage

import {StarRating} from 'rn-inkpad';

const MyComponent = () => {
return <StarRating />;
};

Props

NameTypeDefaultDescription
defaultRatingnumber3Default selected rating.
iconColorstring#FFD700Rating icon color.
justRatingbooleanfalseHide review.
readOnlybooleanfalseTurn on read-only.
reviewsstring[]['Terrible', 'Bad', 'Okay', 'Good', 'Great']Array of reviews.
sizenumber35Icon size.
styleStyleProp<ViewStyle>Custom styles for your rating component.
textColorstring#FFD700Review text color.
textSizenumber30Review text size.
onChange(value: number) => voidFunction that returns the new rating value.
Information

The number of reviews submitted in the array will define the number of stars that will appear.

Usage with props

import React, {useState} from 'react';

import {StarRating} from 'rn-inkpad';

const MyComponent = () => {
const [value, setValue] = useState(1);

return (
<StarRating
defaultRating={1}
iconColor={value <= 2 ? '#FF0000' : value <= 4 ? '#FFD700' : '#7EE081'}
onChange={setValue}
reviews={['Terrible', 'Poor', 'Fair', 'Good', 'Excellent', 'Fabulous']}
size={40}
textColor={value <= 2 ? '#FF0000' : value <= 4 ? '#FFD700' : '#7EE081'}
textSize={35}
/>
);
};

Example with props