Rating
Read-only and interactive star ratings built on native radios.
Read-only: add ar-rating-readonly + disabled on inputs · JS listens for the ar-rating-change CustomEvent.
Interactive
Interactive (click stars)
Selected: 0
<div>
<p class="ar-mb-2 ar-font-semibold">Interactive (click stars)</p>
<div class="ar-rating" data-ar-rating id="site-rating" role="radiogroup" aria-label="Rate 1 to 5 stars">
<input type="radio" name="rating" value="5" id="star5" aria-label="5 stars"><label for="star5"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating" value="4" id="star4" aria-label="4 stars"><label for="star4"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating" value="3" id="star3" aria-label="3 stars"><label for="star3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating" value="2" id="star2" aria-label="2 stars"><label for="star2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating" value="1" id="star1" aria-label="1 star"><label for="star1"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
</div>
<p class="ar-mt-2 ar-text-sm ar-text-gray-600" id="rating-output">Selected: 0</p>
</div><div>
<p className="ar-mb-2 ar-font-semibold">Interactive (click stars)</p>
<div className="ar-rating" data-ar-rating id="site-rating" role="radiogroup" aria-label="Rate 1 to 5 stars">
<input type="radio" name="rating" value={5} id="star5" aria-label="5 stars" /><label htmlFor="star5"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating" value={4} id="star4" aria-label="4 stars" /><label htmlFor="star4"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating" value={3} id="star3" aria-label="3 stars" /><label htmlFor="star3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating" value={2} id="star2" aria-label="2 stars" /><label htmlFor="star2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating" value={1} id="star1" aria-label="1 star" /><label htmlFor="star1"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
</div>
<p className="ar-mt-2 ar-text-sm ar-text-gray-600" id="rating-output">Selected: 0</p>
</div>Read-only
Read-only (3 stars)
<div>
<p class="ar-mb-2 ar-font-semibold">Read-only (3 stars)</p>
<div class="ar-rating ar-rating-readonly" role="radiogroup" aria-label="Read-only rating: 3 of 5 stars">
<input type="radio" name="rating-ro" value="5" id="star-ro5" disabled aria-label="5 stars"><label for="star-ro5"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating-ro" value="4" id="star-ro4" disabled aria-label="4 stars"><label for="star-ro4"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating-ro" value="3" id="star-ro3" checked disabled aria-label="3 stars"><label for="star-ro3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating-ro" value="2" id="star-ro2" disabled aria-label="2 stars"><label for="star-ro2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
<input type="radio" name="rating-ro" value="1" id="star-ro1" disabled aria-label="1 star"><label for="star-ro1"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg></label>
</div>
</div><div>
<p className="ar-mb-2 ar-font-semibold">Read-only (3 stars)</p>
<div className="ar-rating ar-rating-readonly" role="radiogroup" aria-label="Read-only rating: 3 of 5 stars">
<input type="radio" name="rating-ro" value={5} id="star-ro5" disabled aria-label="5 stars" /><label htmlFor="star-ro5"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating-ro" value={4} id="star-ro4" disabled aria-label="4 stars" /><label htmlFor="star-ro4"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating-ro" value={3} id="star-ro3" checked disabled aria-label="3 stars" /><label htmlFor="star-ro3"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating-ro" value={2} id="star-ro2" disabled aria-label="2 stars" /><label htmlFor="star-ro2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
<input type="radio" name="rating-ro" value={1} id="star-ro1" disabled aria-label="1 star" /><label htmlFor="star-ro1"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" /></svg></label>
</div>
</div>