Documentation
Feedback
Guides
Storefront Development

Storefront Development
Storefront development
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.
Example
Code
This field is required.

Usage

Import the component


_10
import { RatingField } from "@faststore/ui";

Import styles

To apply styles, include the following in your stylesheet:

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


Examples

Variants

Error

Example
Code
This field is required.

Design tokens

Design tokens: Label

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)

Design tokens: Error

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)

Data attributes

You can target and override RatingField styles using the following data attributes:
data-fs-rating-field
data-fs-rating-field-label
data-fs-rating-field-error-message

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.
Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
On this page