How to add star ratings in builder.io?

Star rating
How to add star rating using builder like we have an option in Elementor for star rating and changing the values

Hi @ramiz!

Welcome to the builder.io forum.

To create a rating star component, you can use builder data models that can accept the input field[number] for the rating value.

Or else if you are going to fetch the rating stars count from an external source, you can use the below javascript code to render the rating stars

//ratings could be a dynamic data object or an array 
let itemsLen = state.ratings.items.length;
for(let i = 0; i < itemsLen; i++){   
  let rating_stars = [];   
  for(let j=0; j< parseInt(state.ratings.items[i].rating_score); j++){     
    rating_stars[j] = state.star_img; // state.star_img can be a star image or any review.    
  }   
 state.ratings.items[i].rating_stars = rating_stars;
} 

Then you can use the builder repeatForEach feature to loop through the state.ratings and render the stars.

Let us know if have any further questions. Thank you!