React Native · Components
Rating
Giving and showing a rating with stars (or your own icon).
3 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Product card: read only, fractional average and review count
Hearts, out of 10
Satisfaction: a separate face for each score (highlight=single)
😞🙁😐🙂😍
Controlled: write the previewed score yourself
Puan: 3 · Preview: —
Import
Rating
componentGiving and showing a rating with stars (or your own icon). The same calculations as Rating on web (@yasinsensoy/core/rating-math).
- Rate by tapping or sliding the finger over the icons; a label bubble shows while dragging. Vertical scrolling is not blocked.
step={0.5}for half points; read-only values like4.3are drawn proportionally.- With a screen reader swiping up/down changes the score.
Examples
RatingIcon
typeRating icon: a single icon or a function giving an icon per score.
RatingProps
interfaceProps of Rating.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
value? | number | Rating (controlled); 0 if there is no rating. | |
defaultValue? | number | 0 | Initial score (uncontrolled). |
onValueChange? | (value: number) => void | When the score changes. | |
onHoverChange? | (value: number | null) => void | Score previewed while the finger moves over the icons; null on release. | |
max? | number | 5 | Number of icons (the highest score). |
step? | number | 1 | Score step: 0.5 for half stars. Read-only, any value is drawn proportionally. |
icon? | RatingIcon | a star | Icon (filled layer); outline icons are painted filled. |
emptyIcon? | RatingIcon | a muted version of `icon | Empty icon. |
highlight? | "range" | "single" | "range" | range fills all up to the score; single only the chosen one (face scales). |
labels? | readonly ReactNode[] | Name of each score ("Bad"… "Excellent"): in the bubble while dragging, and for screen readers. | |
showValue? | boolean | ((value: number, previewing: boolean) => ReactNode) | Writes the score next to it: true the number (or label), a function your own text. | |
clearable? | boolean | true | Tapping the same score again clears it. |
tone? | Tone | "warning"` (a yellow star) | Color of filled icons. |
size? | Size | "md" | Icon size: 16, 24, 32 pixels. |
readOnly? | boolean | Display only; cannot be tapped. | |
disabled? | boolean | Disabled. | |
accessibilityLabel? | string | Screen reader label. | |
effect? | EffectProp | Effect of the icons ("bounce", "pulse", "glow"…); stays on for the icon under the finger. Defaults to appearance.defaults.rating.effect. See BuiltinEffect. | |
tooltip? | TooltipProp | Tooltip shown on long press (in read-only display). See TooltipProp. | |
style? | StyleProp<ViewStyle> | Container style. |