Documentation
Feedback
Guides
Storefront Development

Storefront Development
Storefront development
Rating

Displays a product rating based on other shoppers' feedback.

The Rating component displays a product’s average rating based on shopper feedback and reviews. It supports customizable icons provided by the Icon component.
Example
Code

Readonly

Actionable


Usage

Import the component


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

Import styles

To apply styles, include the following in your stylesheet:

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


Examples

Readonly

Example
Code

Actionable

Example
Code

Custom icon

Example
Code

Design tokens

Local tokenDefault value/Global token linked
--fs-rating-gapvar(--fs-spacing-0)
--fs-rating-color
var(--fs-color-text)
--fs-rating-color-empty
var(--fs-color-neutral-4)

Design tokens: Icon

Local tokenDefault value/Global token linked
--fs-rating-icon-widthvar(--fs-spacing-3)
--fs-rating-icon-heightvar(--fs-rating-icon-width)

Design tokens: Actionable

Local tokenDefault value/Global token linked
--fs-rating-actionable-gap0
--fs-rating-actionable-icon-widthvar(--fs-rating-icon-width)
--fs-rating-actionable-icon-heightvar(--fs-rating-actionable-icon-width)
--fs-rating-actionable-icon-color
var(--fs-rating-color-empty)
--fs-rating-actionable-icon-color-selected
var(--fs-rating-color)
--fs-rating-button-min-heightvar(--fs-spacing-5)

Data attributes

You can target and override Rating styles using the following data attributes:
data-fs-rating
data-fs-rating-button
data-fs-rating-icon-wrapper
data-fs-rating-icon-outline
data-fs-rating-item="empty" | "partial"
data-fs-rating-actionable="true"

Props

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: cypress, testing library, and jest).fs-rating
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
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
4
Photo of the contributor
Photo of the contributor
Photo of the contributor
Photo of the contributor
On this page