Tesserae

Rating

Description

A component for collecting or displaying star ratings

The Rating component lets users express a value judgment on a 1-to-N star scale. It supports interactive selection, read-only display, and custom star counts.

API reference

class

Rating

public sealed class Rating : ComponentBase<Rating, HTMLElement>

A star-rating component for collecting or displaying ratings.

Constructors

Constructor
Rating
public Rating(int maxStars = 5)

Initializes a new Rating component.

Parameters

maxStars
Maximum number of stars (default 5).

Properties

Property
Rating.Value
public int Value { get ; set ; }

Gets or sets the current rating value (0 = unrated).

Property
Rating.IsReadOnly
public bool IsReadOnly { get ; set ; }

Gets or sets whether the rating is read-only.

Methods

Method
Rating.Color
public Rating Color(string color)

Sets a custom star color.

Method
Rating.OnChange
public Rating OnChange(Action<int> onChange)

Registers a callback for when the value changes.

Method
Rating.SetValue
public Rating SetValue(int value)

Sets the current value.

Method
Rating.ReadOnly
public Rating ReadOnly(bool value = true)

Makes the rating read-only.

Method
Rating.Render
public override HTMLElement Render()

Renders the component's root HTML element.

Samples

Interactive Rating

Read-Only Ratings

Custom Star Count

See also

© 2026 Tesserae. All rights reserved.