
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe simple-star-rating plugin is a custom input component for Sanity Studio that stores the rating data in your content - but displaying those stars on your Gatsby frontend requires some additional work on your part.
Important note: This plugin only works with Sanity Studio v2, which is deprecated. You should consider migrating to Studio v3 when possible.
The plugin stores a simple number value (like 3 for a 3-star rating) in your Sanity documents. To display this as stars on your frontend, you need to:
{
title: "Rating",
name: "rating",
type: "rating"
}Then query it like any other field:
query {
allSanityYourDocumentType {
nodes {
rating
# other fields
}
}
}const StarRating = ({ rating, maxStars = 5 }) => {
return (
<div className="star-rating">
{[...Array(maxStars)].map((_, index) => (
<span key={index}>
{index < rating ? '★' : '☆'}
</span>
))}
</div>
);
};
// Usage in your page/component
<StarRating rating={data.rating} />.star-rating {
color: gold;
font-size: 1.5rem;
}The key thing to understand is that custom input components in Sanity only affect how you input data in the Studio - they don't automatically affect how data is displayed on your frontend. You're responsible for querying that data and rendering it however you want in your Gatsby site.
If you're having trouble querying the field, check your GraphQL schema in Gatsby's GraphiQL explorer (usually at http://localhost:8000/___graphql) to see exactly how the field is named in your schema.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store