Skip to main content
Version: 1.0.5

IRatingProps

@spartanfx/react v1.0.5


@spartanfx/react / IRatingProps

Interface: IRatingProps

Props for the Rating component.

Example

// Interactive controlled rating
const [rating, setRating] = React.useState(3);
<Rating value={rating} onChange={setRating} />

// Read-only display (e.g., showing average rating)
<Rating value={3.5} onChange={() => {}} readOnly />

// With custom colors and label
<Rating
value={rating}
onChange={setRating}
fillColor="#FF6B6B"
label="Rate this product"
/>

// Circle variant with large size
<Rating
value={rating}
onChange={setRating}
variant={RatingVariant.Circle}
size={RatingSize.Large}
/>

Properties

PropertyTypeDescription
appearanceMode?AppearanceModeAppearance mode: light or dark Default AppearanceMode.light
ariaLabel?stringCustom aria-label for the rating container. If not provided, a default label will be generated based on the current value.
className?stringAdditional CSS class name for the root element
classNames?IRatingClassNamesClass name overrides for component elements
fillColor?stringOverride the default fill color for active/filled elements
inlineLabel?booleanWhen true, displays label and rating inline (horizontal). When false, displays label above rating (vertical). Default false
label?stringOptional label text displayed with the rating
max?numberMaximum rating value (number of rating elements) Default 5
min?numberMinimum rating value (inclusive) Default 1
noBorder?booleanWhen true, removes the border and shadow from the container Default false
onChange(value) => voidCallback fired when the user selects a rating value. This is a controlled component - update the value prop in this callback. Not called when readOnly is true. Example const [rating, setRating] = React.useState(3); <Rating value={rating} onChange={setRating} />
onRenderElement?(props) => ReactElementCustom render function for rating elements. When provided, overrides the default icon rendering.
outlineColor?stringOverride the default outline color for empty elements
readOnly?booleanWhen true, the rating is display-only (no hover effects or click handling). Useful for showing average ratings or static displays. Default false
size?RatingSizeSize preset for rating elements Default RatingSize.Medium
style?CSSPropertiesInline styles for the root element
tokens?IRatingTokensCustomization tokens for styling
valuenumberCurrent rating value (supports decimals like 2.5 for half-filled elements)
variant?RatingVariantVisual variant for rating elements Default RatingVariant.Star