Rating
WdRating
Applicable Scenarios
For rating input and display, using intuitive icons to represent the rating value.
Basic Capabilities Description
- The basic properties support selecting the component size and setting the current rating value.
- The advanced properties of the Rating component support configuring min value, max value, numerical adjustment step size, icon color (effective when using built-in icons), custom icons, and a tooltip copy generation function.
Extended Scenarios Description
How to Configure Step Size and Icon Display Style
Example
Configure the step size to 0.5, adjust the icon color, and set up custom icons.
Configuration Method
Configure Step Size: In the Scoring Attributes Area - Score Selector - Numerical Adjustment Step Size, enter 0.5 as the target step size.
Adjust icon color: In the Scoring Attributes Area - Score Selector - Icon Selected Color, enter rgb(255, 119, 158) as the target color; in the Icon Unselected Color input field below, enter rgb(132, 106, 165) as the target color.
Configure custom icons: In the Scoring Attributes Area - Score Selector - Default Icon, you can select the icon representing the current rating value; in the Scoring Attributes Area - Score Selector - Background Icon, you can select the icon to be displayed in the background. Both support selecting built-in icons and custom icons.
Example
Interactive Preview
Configure Minimum Value, Maximum Value, and Step Size
Custom Icon Color
Custom Icons
Configure Different Sizes
Custom Prompt Text
{
tooltip: ({ value }) => `Current rating value is: ${value}`;
}
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
|---|
| Display Headlines | labelVisible | boolean | Default value: true |
| Title alignment | labelAlign | string | In the scenario, the form by default follows the title alignment configuration of the form container. |
| Line break in heading | labelWrap | boolean | If the title content is too long when closed, show one line with overflow omitted; when enabled, show with line breaks. In form scenarios, it follows the form container's title line break configuration by default. |
| Title position | layout | string | Set title display position in form component. In the scenario, it follows the title position configuration of the form container by default. |
| Title width | labelWidth | string | In the scenario, the form follows the title width configuration of the form container by default. |
| Heading Note | labelTips | string | Configure tooltip content for the heading |
| Minimum value | min | number | 0 |
| Maximum value | max | number | Default value: 5 |
| Adjust step size | step | number | Minimum range for single score change Default value: 1 |
| default icon | icon | string | Default score icon Default value: "td:star-filled" |
| custom icon | iconSrc | string | Set custom icon address |
| Unselected icon | backgroundIcon | string | Score background icon |
| custom unselected icon | backgroundIconSrc | string | Set custom icon address |
| Selected icon color | foregroundColor | string | Default value: "#ffcf48" |
| Icon unselected color | backgroundColor | string | Default value: "#bfbfbf" |
| Display underscore on mobile terminal | borderedH5 | boolean | After closing, the mobile terminal does not show the bottom underline Default value: true |
callbacks | object | configuration-related functions | |
| Status. | status | string | Default value: "edit" |
| Required | required | boolean | Enable required for this component, value cannot be empty |
| Required identifier | requiredFlag | boolean | Enabled, the component will display a required asterisk tag if mandatory. Default value: true |
| Required validation note | requiredMsg | string | Enable required, prompting message when component value is empty Default value: "该项为必填项" |
| Bound field | name | string | The Key of the form field is used to match the field identifier of the data model when submitting data. Ensure uniqueness inline. |
| Title content. | label | string | Example: "标题" |
| Score | value | number | Current Score |
| Component size | size | string | Control the size of the score component Default value: "sm" |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
|---|
| value change | change | object
| Compatible with all platforms | - |
Property API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName, such as $w.input1.value. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
|---|
| Bound field | name | string | The Key of the form field is used to match the field identifier of the data model when submitting data. Ensure uniqueness inline. |
| Title content. | label | string | |
| Score | value | number | Current Score |
| Minimum value | min | number | |
| Maximum value | max | number | |
| Adjust step size | step | number | Minimum range for single score change |
| Indicates whether to display | visible | boolean | Whether to display the component |
| Whether to disable | disabled | boolean | Component Disabled |
| Specify whether it is read-only or not. | readOnly | boolean | Whether the component is read-only |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
|---|
| set value | setValue | number值 | 通过 $w.id1.setValue("weda") 设置组件值 |
| Show/Hide Settings | setVisible | boolean显示 | Set the component to hidden via $w.id1.setVisible(false) |
| Set Disabled | setDisabled | boolean禁用 | Set the component to disabled with $w.id1.setDisabled(true) |
| Clear value | clearValue | Clear the component value with $w.id1.clearValue() | |
| Set as read-only | setReadOnly | boolean只读 | Set the component to read-only via $w.id1.setReadOnly(true) |
| Trigger validation | handleValidate | Validate the component value via $w.id1.handleValidate() | |
| Clear verification | clearValidate | Clear component validation via $w.id1.clearValidate() |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn, and control individual component styles with :scope. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
|---|
| root element | .wd-rating-root | Outermost component element |
| H5 root element | .wd-h5-rating-root | Settable root element style for the H5 side |
| PC-side root element | .wd-pc-rating-root | Settable root element style for the PC side |
| Mini program root element | .wd-mp-rating-root | Settable root element style for mini program |
| Component title style | .wd-rating-root .wd-form-item-wrap__label | Component title element |
| Editing status - Verification information | .wd-rating-root .wd-g-text-error | Set component verification information style |
| prompt text | .wd-rating-root .wd-form-item__help-text | Set the text style of the component prompt |
| ScoreScore component | .wd-rating | |
| Disabled State Score Component | .wd-rating.is-disabled | |
| Disabled State Score Component | .wd-rating.is-readonly | |
| Fill the icon container | .wd-rating__full-icons-container | Fill the parent container element of icon elements |
| background icon container | .wd-rating__empty-icons-container | Background icon elements' parent container element |
| icon container | .wd-rating__icon-container | Parent container element of the icon element |
| Icon. | .wd-rating__icon | Icon element |