salla-rating-stars
Shows a five star rating, either as a read-only display of a score or as an input the customer clicks to pick a rating.
Shows a five star rating, either as a read-only display of a score or as an input the customer clicks to pick a rating. Use the read-only form on product cards and review lists, and the editable form in review forms.
With a value and without editable, it displays that many filled stars (plus the review count when reviews is above 0). With no value, or with editable, it renders five buttons and a hidden input named by name, so the picked rating (1 to 5) is submitted with the surrounding form. In editable mode a given value is pre-selected until the customer picks one.
The star buttons set aria-pressed on the chosen star. The text label is hidden from assistive technology while it is empty.
Use it
In HTML or JSX, use the tag <salla-rating-stars> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).
import { SallaRatingStars } from '@salla.sa/twilight-components-react/rating-stars';Client-only. On the server this wrapper renders a placeholder (a skeleton, or nothing), and the real component mounts in the browser. Do not rely on it for content that search engines must see.
Try it
Example
import { SallaRatingStars } from '@salla.sa/twilight-components-react/rating-stars';
export function Example() {
return (
<SallaRatingStars value={4} reviews={120} size="small" />
);
}import { SallaRatingStars } from '@salla.sa/twilight-components-react/rating-stars';
export function Example() {
return (
<form>
<SallaRatingStars name="rating" withLabel />
</form>
);
}Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
editable | editable | Makes the rating an input the customer can click. Without it, the stars are read-only whenever value is set. | boolean | false |
labelBeforeStars | label-before-stars | Places the description label before the stars instead of after. Only has an effect together with with-label. | boolean | false |
name | name | Name of the hidden input that holds the picked rating (1 to 5) in the editable form. | string | 'rating' |
reviews | reviews | Number of reviews shown in brackets after the stars. Nothing is shown when it is 0. Only used in read-only mode. | number | 0 |
size | size | Size of the stars: large, medium, small or mini. It is added as a CSS class (s-rating-stars-<size>) on each star. | "large" | "medium" | "mini" | "small" | 'medium' |
tag | tag | Only switches the CSS class of the text label between s-rating-stars-label (true) and s-rating-stars-label-without-tag (false), so a theme can style them differently. | boolean | true |
value | value | The rating, from 1 to 5. In read-only mode this many stars are filled. With editable it is the pre-selected rating. Also picks the text label when with-label is set. | number | |
withLabel | with-label | Shows a text label (such as poor, good or excellent) for the current or hovered rating. | boolean |
Related
Used inside: <salla-comment-factors>, <salla-comment-item>, <salla-filters-widget>, <salla-rating-modal>, <salla-rating-modal-v2>, <salla-review-order-item>, <salla-reviews>, <salla-reviews-summary>.
salla-rating-modal
The modal where a customer rates an order: its products, and (when available) the store and shipping, with optional comments, images and videos.
salla-review-card
A card for one customer review: images (a swipeable slider when there are several), reviewer name with a verified mark, 5 star rating, review text, and a link to the reviewed product with its image an