Skip to content

RatingField

RatingField provides a Cratis-owned star-rating radio group with labeled options bound to a number property.

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.
namestringgeneratedOptional native radio-group name. Every star in the component shares one name.
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.
ptcomponent-specific partsCratis-owned HTML attributes for stable parts.
ptOptionsobjectLegacy compatibility prop; ignored.
unstyledbooleanfalseLegacy compatibility prop; ignored.
  • Default value is 0 (no rating selected).
  • The bound value is the selected star count (1stars).
  • Stars use native arrow-key radio navigation with one tab stop.
  • Validation state is reflected through aria-invalid and data-invalid.