Skip to content

RatingField

RatingField provides a star-rating input backed by the PrimeReact Rating component, bound to a number property on a command.

import { CommandDialog } from '@cratis/components/CommandDialog';
import { RatingField } from '@cratis/components/CommandForm';
<CommandDialog command={SubmitReview} visible={visible} onCancel={() => setVisible(false)}>
<RatingField<SubmitReview> value={c => c.rating} stars={5} />
</CommandDialog>
PropTypeDefaultDescription
value(instance: TCommand) => unknownRequired. Accessor that returns the bound property from the command instance. Pass the command type as the generic parameter for full type safety.
starsnumber5Number of stars to display.
starAriaLabel(starValue: number) => string"1 star", "2 stars", …Builds the accessible name for each star, from the 1-based star value. Override to localize.
classNamestringExtra CSS class name.
ptRatingRootProps['pt']PrimeReact pass-through configuration.
ptOptionsRatingRootProps['ptOptions']PrimeReact pass-through options.
unstyledbooleanfalseDisables every base PrimeReact style on the underlying Rating.
  • Default value is 0 (no rating selected).
  • The bound value is the selected star count (1stars).
  • Validation state is reflected via the PrimeReact invalid flag.