Ship faster with goilerplate templUI Pro

Rating

Interactive rating component for capturing user feedback and displaying scores.

Source Tailwind CSS JavaScript

Installation

templui add rating

Load the script once in your layout:

<head>
  @rating.Script()
</head>

Examples

With Label

Styles

Precision (Read-Only)

Max Values

Form

Rate the quality of the product you received.

Please rate the product quality.

API Reference

Required parameter
Hover for description

Rating

Main rating component container.

Name Type Default
ID

Unique identifier for the rating component

string
""
Class

Additional CSS classes to apply to the rating container

string
""
Attributes

Additional HTML attributes to apply to the rating container

templ.Attributes
nil
Value

Current rating value

float64
0
ReadOnly

Whether the rating is read-only

bool
false
Precision

Precision for rating values (e.g., 0.5 for half-star ratings)

float64
1.0
Name

Name attribute for the hidden input field

string
""
OnlyInteger

Whether to only allow integer rating values

bool
false

Rating.Group

Container for grouping rating items.

Name Type Default
ID

Unique identifier for the group element

string
""
Class

Additional CSS classes to apply to the group

string
""
Attributes

Additional HTML attributes to apply to the group

templ.Attributes
nil

Rating.Item

Individual rating item (star, heart, emoji).

Name Type Default
ID

Unique identifier for the item element

string
""
Class

Additional CSS classes to apply to the item

string
""
Attributes

Additional HTML attributes to apply to the item

templ.Attributes
nil
Value

Numeric value for this rating item

int
0
Style

Visual style for the rating item (star, heart, emoji)

Style
star