Components Rating

Rating

A read-only star rating.

Basic Rating

Basic rating
Half
Empty
Including label
3.3 out of 5
heex
          <.rating rating={4} total={5} />
<.rating rating={2.5} total={5} />
<.rating rating={0} total={5} />
<.rating include_label rating={3.3} total={5} />

        

Properties

elixir
            # <.rating>
  attr(:rating, :any, default: 0, doc: "The rating to display (integer or float). A number between 0 and `total`")
  attr(:round_to_nearest_half, :boolean, default: true, doc: "Whether to round the rating to the nearest half star (eg. 3.3 -> 3.5"). Defaults to false)
  attr(:total, :integer, default: 5, doc: "The total number of stars to display. Defaults to 5")
  attr(:class, :string, default: nil, doc: "Any additional CSS classes for the rating wrapper")
  attr(:star_class, :string, default: nil, doc: "Any additional CSS classes for the individual stars. Eg. you could change the size of the stars with 'h-10 w-10'")
  attr(:include_label, :boolean, default: false, doc: "Whether to include an automatically generated rating label")
  attr(:label_class, :string, default: nil, doc: "Any additional CSS classes for the rating label")