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-hapticsUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | Stars filled; read-only ratings round to the nearest star. | |
| onChange | (value: number) => void | – | Leave out for a read-only rating. |
| max | number | 5 | Number of stars. |
| size | number | 28 | Star size. Tap targets stay at least 44 pt. |
| accessibilityLabel | string | "Rating" | What is being rated. Screen readers adjust it by swiping up and down. |