Mobile › Inputs

Rating

Stars to rate something, or to show an average. Tap the chosen star again to clear it.

Installation

npx expo install plankui-mobile react-native-safe-area-context expo-haptics

Usage

import { Rating } from "plankui-mobile";

const [stars, setStars] = useState(4);

<Rating value={stars} onChange={setStars} accessibilityLabel="Your rating" />
<Rating value={4.6} size={16} />

iOS and Android

iOS: Stars in the theme's warning colour, as on App Store reviews.

Android: The same stars, with a ripple-free press scale.

API reference

PropTypeDefaultDescription
valuenumberStars filled; read-only ratings round to the nearest star.
onChange(value: number) => void–Leave out for a read-only rating.
maxnumber5Number of stars.
sizenumber28Star size. Tap targets stay at least 44 pt.
accessibilityLabelstring"Rating"What is being rated. Screen readers adjust it by swiping up and down.