Get started with the rating component to show an aggregate of reviews and scores in the forms of stars or numbers.
You can find multiple examples on this page including different styles, sizes, and variants of the rating component and other associated elements such as a comment or card.
Setup
Let’s import all necessary components in the script tag. We import a heart, thumb-up, and smiley icons, but you can use any icons as you like.
Set the total,rating, and ratings prop for AdvancedRation component. Use the rating slot for Rating component with the total and rating props. Use the globalText slot for additional information.
3.21 out of 5
1,745 global ratings
5 star
70%
4 star
17%
3 star
8%
2 star
4%
1 star
1%
<AdvancedRatingratings={[{label:'5star',rating:70},{label:'4star',rating:17},{label:'3star',rating:8},{label:'2star',rating:4},{label:'1star',rating:1}]}><spanslot="rating"><Ratingtotal={5}rating={3.21}><pslot="text"class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">3.21 out of 5</p></Rating></span><pslot="globalText"class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">1,745 global ratings</p></AdvancedRating>
Different icon
As we describe in the Rating component, you can change an icon in the ratingUp and ratingDown in the Rating component.
3.21 out of 5
1,745 global ratings
5 star
70%
4 star
17%
3 star
8%
2 star
4%
1 star
1%
<AdvancedRatingratings={[{label:'5star',rating:70},{label:'4star',rating:17},{label:'3star',rating:8},{label:'2star',rating:4},{label:'1star',rating:1}]}><spanslot="rating"><Ratingtotal={5}rating={3.21}ceil><spanslot="ratingUp"><ThumbUpclass="text-yellow-300 dark:text-yellow-200"/></span><spanslot="ratingDown"><ThumbUpclass="text-gray-300 dark:text-gray-500"/></span><pslot="text"class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">3.21 out of 5</p></Rating></span><pslot="globalText"class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">1,745 global ratings</p></AdvancedRating>
Use this component to show a single rating comment and its score alongside other components such as the user profile avatar, name, post date, and more.
Jese Leos
Thinking to buy another one!
This is my third Invicta Pro Diver. They are just fantastic value for money. This one arrived
yesterday and the first thing I did was set the time, popped on an identical strap from
another Invicta and went in the shower with it to test the waterproofing.... No problems.
It is obviously not the same build quality as those very expensive watches. But that is like
comparing a Citroën to a Ferrari. This watch was well under £100! An absolute bargain.
<script>exportlet comment ={id:'1',user:{name:'Jese Leos',img:{src:'/images/profile-picture-2.webp',alt:'Jese Leos'},joined:'Joined on August 2014'},total:5,rating:4.5,heading:'Thinking to buy another one!',address:'the UK',datetime:'2022-03-25'};</script><RatingComment{comment}helpfullink="/"abuselink="/"><pclass="mb-2 font-light text-gray-500 dark:text-gray-400">
This is my third Invicta Pro Diver. They are just fantastic value for money. This one arrived
yesterday and the first thing I did was set the time, popped on an identical strap from
another Invicta and went in the shower with it to test the waterproofing.... No problems.
</p><pclass="mb-3 font-light text-gray-500 dark:text-gray-400">
It is obviously not the same build quality as those very expensive watches. But that is like
comparing a Citroën to a Ferrari. This watch was well under £100! An absolute bargain.
</p><ahref="/"class="block mb-5 text-sm font-medium text-blue-600 hover:underline dark:text-blue-500">Read more</a><svelte:fragmentslot="evaluation">19 people found this helpful</svelte:fragment></RatingComment>
Review content
Use this component to show the review content from a user alongside the avatar, location, details, and the score inside a card element.
Jese Leos
United States
Apartament with City View
3 nights December 2021
Family
Spotless, good appliances, excellent layout, host was genuinely nice and helpful.
8.79
The flat was spotless, very comfortable, and the host was amazing. I highly recommend this
accommodation for anyone visiting Brasov city centre. It's quite a while since we are no
longer using hotel facilities but self contained places. And the main reason is poor
cleanliness and staff not being trained properly. This place exceeded our expectation and will
return for sure.
It is obviously not the same build quality as those very expensive watches. But that is like
comparing a Citroën to a Ferrari. This watch was well under £100! An absolute bargain.
<Review{review}><pclass="mb-2 font-light text-gray-500 dark:text-gray-400">
The flat was spotless, very comfortable, and the host was amazing. I highly recommend this
accommodation for anyone visiting Brasov city centre. It's quite a while since we are no
longer using hotel facilities but self contained places. And the main reason is poor
cleanliness and staff not being trained properly. This place exceeded our expectation and will
return for sure.
</p><pclass="mb-5 font-light text-gray-500 dark:text-gray-400">
It is obviously not the same build quality as those very expensive watches. But that is like
comparing a Citroën to a Ferrari. This watch was well under £100! An absolute bargain.
</p><svelte:fragmentslot="item"><OfficeBuildingsize="16"class="mr-2"variation="solid"/>
{review.item}
</svelte:fragment><svelte:fragmentslot="option1"><Calendarsize="16"class="mr-2"variation="solid"/>
{review.option1}
</svelte:fragment><svelte:fragmentslot="option2"><UserGroupsize="16"class="mr-2"variation="solid"/>
{review.option2}
</svelte:fragment><asideclass="flex items-center mt-3 space-x-5"><ahref="/"class="inline-flex items-center text-sm font-medium text-blue-600 hover:underline dark:text-blue-500"><ThumbUpsize="18"variation="solid"class="mr-1"/>
Helpful
</a><ahref="/"class="inline-flex items-center text-sm font-medium text-blue-600 hover:underline dark:text-blue-500 group"><ThumbDownsize="18"variation="solid"class="mr-1"/>
Not helpful
</a></aside></Review>
Props
The component has the following props, type, and default values. See types
page for type information.