Rating
A flexible star rating component with multiple shapes, fractional precision, tooltips, and full keyboard support.
Basic Usage
Default Rating
Click a star to set the value. Click the same star again to clear.
import { Rating } from 'fluxo-ui';
const [value, setValue] = useState(3);
<Rating value={value} onChange={setValue} />
<Rating defaultValue={4} showValue />
<Rating defaultValue={3.5} precision={0.5} showValue />Shapes
Choose from five built-in shapes using the shape prop.
Shapes
Five built-in shapes: star, heart, thumb, circle, and square.
<Rating shape="star" defaultValue={3} />
<Rating shape="heart" variant="danger" defaultValue={3} />
<Rating shape="thumb" variant="primary" defaultValue={3} />
<Rating shape="circle" variant="info" defaultValue={3} />
<Rating shape="square" variant="success" defaultValue={3} />Sizes
Sizes
Five sizes from xs to xl with proportional icon scaling.
<Rating defaultValue={3} size="xs" />
<Rating defaultValue={3} size="sm" />
<Rating defaultValue={3} size="md" />
<Rating defaultValue={3} size="lg" />
<Rating defaultValue={3} size="xl" />Variants
Color Variants
Six semantic color variants using theme CSS variables.
<Rating variant="warning" defaultValue={4} />
<Rating variant="primary" defaultValue={4} />
<Rating variant="success" defaultValue={4} />
<Rating variant="danger" defaultValue={4} />
<Rating variant="info" defaultValue={4} />Precision
Precision
Click anywhere on a star to set fractional values. Supports 1, 0.5, or 0.1 precision.
<Rating precision={1} defaultValue={3} showValue />
<Rating precision={0.5} defaultValue={3.5} showValue />
<Rating precision={0.1} defaultValue={3.7} showValue />Tooltips & Labels
Tooltips & Labels
Show a dynamic label based on the current hover or selection, plus per-star tooltips.
<Rating
tooltips={['Terrible', 'Bad', 'Okay', 'Good', 'Excellent']}
labels={['Terrible', 'Bad', 'Okay', 'Good', 'Excellent']}
defaultValue={4}
/>Import
import { Rating } from 'fluxo-ui';
import type { RatingProps, RatingShape, RatingSize, RatingVariant, RatingPrecision } from 'fluxo-ui';Props
valuenumberControlled value of the rating.
valuenumberControlled value of the rating.
defaultValuenumber"0"Initial value for uncontrolled usage.
defaultValuenumber"0"Initial value for uncontrolled usage.
countnumber"5"Total number of rating items.
countnumber"5"Total number of rating items.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'"'md'"Icon size. Use 'xxl' (~48px) on touch surfaces to clear the 44x44 touch-target requirement.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'"'md'"Icon size. Use 'xxl' (~48px) on touch surfaces to clear the 44x44 touch-target requirement.
variant'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'"'warning'"Color variant.
variant'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'"'warning'"Color variant.
shape'star' | 'heart' | 'circle' | 'square' | 'thumb'"'star'"Built-in icon shape.
shape'star' | 'heart' | 'circle' | 'square' | 'thumb'"'star'"Built-in icon shape.
precision1 | 0.5 | 0.1"1"Increment precision. Use 0.5 for half-star and 0.1 for decimal ratings.
precision1 | 0.5 | 0.1"1"Increment precision. Use 0.5 for half-star and 0.1 for decimal ratings.
readOnlyboolean"false"Display-only mode.
readOnlyboolean"false"Display-only mode.
disabledboolean"false"Disable interaction.
disabledboolean"false"Disable interaction.
allowClearboolean"true"Clicking the current value clears it (precision=1 only).
allowClearboolean"true"Clicking the current value clears it (precision=1 only).
showValueboolean"false"Display the current value next to the rating.
showValueboolean"false"Display the current value next to the rating.
valueFormat(value, max) => ReactNodeCustom formatter for the displayed value.
valueFormat(value, max) => ReactNodeCustom formatter for the displayed value.
tooltipsstring[]Per-star tooltip text shown on hover.
tooltipsstring[]Per-star tooltip text shown on hover.
labelsstring[]Labels shown next to the rating, changing with hover/selection.
labelsstring[]Labels shown next to the rating, changing with hover/selection.
iconReactNodeOverride the filled icon.
iconReactNodeOverride the filled icon.
emptyIconReactNodeOverride the empty icon.
emptyIconReactNodeOverride the empty icon.
onChange(value: number) => voidCalled when the user selects a new value.
onChange(value: number) => voidCalled when the user selects a new value.
onHoverChange(value: number) => voidCalled when the hovered value changes.
onHoverChange(value: number) => voidCalled when the hovered value changes.
Features
Five Shapes
Star, heart, thumb, circle, and square icons built-in — plus custom icon support.
Fractional Precision
Click anywhere on an icon for half-star or decimal ratings with pixel-accurate fills.
Tooltips & Labels
Per-star tooltips and dynamic labels that update on hover for expressive feedback.
Keyboard Accessible
Arrow keys, Home/End, and ARIA slider roles for full keyboard navigation.