Documentation
Feedback
Guides
Storefront Development

Storefront Development
FastStore
RatingField
The RatingField component allows users to submit ratings when submitting product reviews. It wraps the Rating component, which displays the rating system, and the associated Label component, which provides a text description for the rating field.

Overview

Example
Code
This field is required.

Import

Import the component from the @faststore/ui package.

_10
import { RatingField } from '@faststore/ui'

Import Styles into your FastStore project

To apply the styles of this component in your FastStore project, import the following into your stylesheet:

_10
@import '@faststore/ui/src/components/molecules/RatingField/styles.scss';

For more information, refer to Importing FastStore UI component styles.

Props

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: cypress, testing library, and jest).fs-rating-field
idstringID to identify input and corresponding label.
label*stringThe text displayed to identify the input rating.
errorstringThe error message displayed when an error occurs.
ratingRefMutableRefObject<HTMLUListElement>Component's ref.
lengthnumberThe length of child elements.5
valuenumberThe current value of the rating, based on the quantity of child elements.0
iconstring | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortalIcon to represent the rating score unit (e.g.: a <Icon name="Star" /> component)
onChange(value: number) => voidFunction to be triggered when Rating option change. This should only be used if you and an actionable rating list.
disabledfalse | trueSpecifies that the actionable rating should be disabled.

Design Tokens

Nested elements

Label


_10
<RatingField label="Rate the product from 1 to 5 stars" id="rating-field-default" />

Local tokenDefault value/Global token linked
--fs-rating-field-label-color
var(--fs-color-text-light)
--fs-rating-field-label-sizevar(--fs-text-size-2)
--fs-rating-field-label-line-heightvar(--fs-text-size-4)

Variants

Error

This field is required.

_10
<RatingField label="Rate the product from 1 to 5 stars" id="rating-field-error" error="This field is required." />

Local tokenDefault value/Global token linked
--fs-rating-field-error-message-sizevar(--fs-text-size-legend)
--fs-rating-field-error-message-line-height1.1
--fs-rating-field-error-message-color
var(--fs-color-danger-text)

Customization

For further customization, you can use the following data attributes:
data-fs-rating-field
data-fs-rating-field-label
data-fs-rating-field-error-message
Contributors
1
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
On this page