DEV Community

Cover image for Introduction to the next Scoring Component
liu yang
liu yang

Posted on

Introduction to the next Scoring Component

Scoring Component Introduction

Properties

stars

  • Description: Sets the total number of ratings. Defaults to 5 if a value less than or equal to 0 is set.
  • Card Ability: Supported in ArkTS cards from API version 9.
  • Meta - service API: Supported in meta - services from API version 11.
  • System Capability: SystemCapability.ArkUI.ArkUI.Full
  • Parameters:
Parameter Name Type Required Description
value number Yes The total number of ratings. Default: 5

stepSize

  • Description: Sets the step size for rating operations. Defaults to 0.5 if a value less than 0.1 is set.
  • Card Ability: Supported in ArkTS cards from API version 9.
  • Meta - service API: Supported in meta - services from API version 11.
  • System Capability: SystemCapability.ArkUI.ArkUI.Full
  • Parameters:
Parameter Name Type Required Description
value number Yes The step size for rating operations. Default: 0.5. Range: [0.1, stars]

starStyle

  • Description: Sets the style for the rating. Refer to the Image component for supported image types.
  • Supported Image Types: Local and network images are supported. PixelMap type and Resource resources are not supported.
  • Default Behavior: Images are loaded asynchronously. Synchronous loading is not supported.
  • Card Ability: Supported in ArkTS cards from API version 9.
  • Meta - service API: Supported in meta - services from API version 11.
  • System Capability: SystemCapability.ArkUI.ArkUI.Full
  • Parameters:
Parameter Name Type Required Description
value {backgroundUri: string, foregroundUri: string, secondaryUri?: string} Yes backgroundUri: The image link for unselected stars. Can be custom - defined or use the system default. foregroundUri: The image path for selected stars. Can be custom - defined or use the system default. secondaryUri: The image path for partially selected stars. Can be custom - defined or use the system default. If the image path for backgroundUri, foregroundUri, or secondaryUri is incorrect, the image will not be displayed. If backgroundUri or foregroundUri is set to undefined or an empty string, the system default star image will be loaded. If secondaryUri is not set or is undefined or an empty string, it will prioritize being set to backgroundUri, which is equivalent to only setting foregroundUri and backgroundUri.

contentModifier

  • Description: A method for customizing the content area of the Rating component.
  • System Capability: SystemCapability.ArkUI.ArkUI.Full
  • Parameters:
Parameter Name Type Required Description
modifier ContentModifier Yes A content modifier that developers need to implement by defining a custom class to realize the ContentModifier interface.

Events

onChange

  • Description: Triggers this callback when the rating stars change.
  • Card Ability: Supported in ArkTS cards from API version 9.
  • Meta - service API: Supported in meta - services from API version 11.
  • System Capability: SystemCapability.ArkUI.ArkUI.Full
  • Parameters:
Parameter Name Type Required Description
value number Yes The rating value.

Keyboard Focus Specification

Key Function Description
Tab Switch focus between components.
Left/Right Arrow Keys Increase or decrease the rating preview (step size is step) without changing the actual rating.
Home Move to the first star without changing the actual rating.
End Move to the last star without changing the actual rating.
Space/Enter Submit the rating result based on the current rating.

Top comments (0)