Components · Interactive
Rating
StableAdded v0.0.1
Star rating input, supports controlled and read-only modes.
import { Rating } from '@nexub/react';Playground
Props
size
<Rating value={val} onValueChange={setVal} />Examples
Default
Read-only
Sizes
States
defaultreadOnlysize="sm"size="md"size="lg"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | The controlled rating value. |
| max | number | 5 | Maximum number of stars. |
| readOnly | boolean | false | Prevents user interaction when true. |
| size | 'sm' | 'md' | 'lg' | 'md' | Size of the star icons. |
| onValueChange | ((value: number) => void) | — | Callback fired when the user selects a new rating. |
On iOS & Android: Rating
@nexub/react-nativeAlpha
import { Rating } from '@nexub/react-native';
<Rating value={stars} onValueChange={setStars} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Screen readers | A radio group: one radio per star, arrow keys move. | One adjustable control: swipe up or down to change the value; it can go down to 0. |
| Feedback | Stars preview on hover. | No hover; a selection haptic when the value changes. |
| Hit area | The star. | 44pt tall with hitSlop; sideways each star keeps its own width so neighbours do not overlap. |
| Props | value only; aria-label names it. | Adds defaultValue and label. |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
Rating props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | — |
| defaultValue | number | 0 | — |
| onValueChange | (value: number) => void | — | — |
| max | number | 5 | — |
| readOnly | boolean | false | — |
| size | 'sm' | 'md' | 'lg' | 'md' | — |
| label | string | messages.rating | Accessible name. |
| style | StyleProp<ViewStyle> | — | — |