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).
- React
- Vue
- Angular
import { TkRating } from '@takeoff-ui/react'
import { TkRating } from '@takeoff-ui/vue'
import { TkRating } from '@takeoff-ui/angular'
Design Type​
This field specifies the design type of the component.
- React
- Vue
- Angular
<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)}
/>
<TkRating type="star" v-model="2" />
<TkRating type="heart" v-model="2.5" />
<TkRating type="dot" v-model="4" />
<TKRating type="number" v-model="3"
<tk-rating type="star" [value]="2" />
<tk-rating type="heart" [value]="2.5" />
<tk-rating type="dot" [value]="4" />
<tk-rating type="number" [value]="3" />
Show Rating Value​
Determines whether to show the numerical rating value under to the icon.
- React
- Vue
- Angular
<TkRating type="star" value={2} showRatingValue />
<TkRating type="heart" value={2.5} showRatingValue />
<TkRating type="dot" value={3.5} showRatingValue />
<TkRating type="star" :value="2" :showRatingValue.prop="true" />
<TkRating type="heart" :value="2.5" :showRatingValue.prop="true" />
<TkRating type="dot" :value="3.5" :showRatingValue.prop="true" />
<tk-rating type="star" [value]="2" showRatingValue />
<tk-rating type="heart" [value]="2.5" showRatingValue />
<tk-rating type="dot" [value]="3.5" showRatingValue />
Max Rating​
The maximum rating value. Possible options are 5 or 10.
- React
- Vue
- Angular
<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} />
<TkRating
type="star"
:value="2"
:showRatingValue.prop="true"
:maxRating="3"
/>
<TkRating
type="star"
:value="2.5"
:showRatingValue.prop="true"
:maxRating="5"
/>
<TkRating
type="star"
:value="3.5"
:showRatingValue.prop="true"
:maxRating="10"
/>
<tk-rating type="star" [value]="2.5" showRatingValue [maxRating]="3" />
<tk-rating type="star" [value]="4" showRatingValue [maxRating]="6" />
<tk-rating type="star" [value]="5.5" showRatingValue [maxRating]="10" />
States​
This example illustrates the disabled state of the rating.
- React
- Vue
- Angular
<TkRating type="star" value={3.5} showRatingValue disabled />
<TkRating type="star" value={3.5} showRatingValue readonly />
<TkRating type="star" value="3.5" :showRatingValue.prop="true" disabled />
<TkRating type="star" value="3.5" :showRatingValue.prop="true" readonly />
<tk-rating type="star" [value]="3.5" showRatingValue disabled />
<tk-rating type="star" [value]="3.5" showRatingValue readonly />
API​
Props​
Name | Type | Default | Description |
---|---|---|---|
boolean | false | The user cannot interact with the input. | |
number | 5 | The maximum rating value. Possible options are 5 or 10. | |
boolean | false | If true , the user cannot modify the value. | |
boolean | false | Determines 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'. | |
number | 0 | The currently selected rating value. |
Events​
Name | Description |
---|---|
tk-change | Emitted when the value has changed. |