Skip to main content

Rating

The TkRating component is a customizable rating input element that allows users to select a value from a series of icons (such as stars, hearts, or dot).

import { TkRating } from '@takeoff-ui/react'

Design Type​

This field specifies the design type of the component.

View Code
<TkRating
type="star"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkRating
type="heart"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkRating
type="dot"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkRating
type="number"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>

Show Rating Value​

Determines whether to show the numerical rating value under to the icon.

View Code
<TkRating type="star" value={2} showRatingValue />
<TkRating type="heart" value={2.5} showRatingValue />
<TkRating type="dot" value={3.5} showRatingValue />

Max Rating​

The maximum rating value. Possible options are 5 or 10.

View Code
<TkRating type="star" value={2.5} showRatingValue maxRating={3} />
<TkRating type="star" value={4} showRatingValue maxRating={6} />
<TkRating type="star" value={5.5} showRatingValue maxRating={10} />

States​

This example illustrates the disabled state of the rating.

View Code
<TkRating type="star" value={3.5} showRatingValue disabled />
<TkRating type="star" value={3.5} showRatingValue readonly />

API​

Props​

NameTypeDefaultDescription
booleanfalseThe user cannot interact with the input.
number5The maximum rating value. Possible options are 5 or 10.
booleanfalseIf true, the user cannot modify the value.
booleanfalseDetermines whether to show the numerical rating value under to the icon.
"dot", "heart", "number", "star"'star'The type of icon to display for each rating element. Options include 'star', 'heart', 'dot' and 'number'.
number0The currently selected rating value.

Events​

NameDescription
tk-changeEmitted when the value has changed.