Rating
Lets users choose a rating from a radio group, or shows a read-only rating value.
beta
Try it
<Rating label="Deployment experience" name="playground-deployment-rating" value={3} />Examples
Deployment feedback
<script lang="ts">
import Rating from '@tcpsystems/ui/foundation/Rating';
const uid = $props.id();
let score = $state(0);
</script>
<form onchange={(event) => score = Number((event.target as HTMLInputElement).value)}>
<Rating label="How was this deployment?" name={uid} value={score} />
<p>{score ? `Your score: ${score} of 5` : 'Choose a score.'}</p>
</form>Readonly
<script lang="ts">
import Rating from '@tcpsystems/ui/foundation/Rating';
import Stack from '@tcpsystems/ui/foundation/Stack';
const uid = $props.id();
</script>
<Stack>
<Rating label="Team satisfaction" name={`${uid}-team`} value={4} readonly />
<Rating label="No reviews yet" name={`${uid}-empty`} value={0} readonly />
</Stack>Ten point scale
<script lang="ts">
import Rating from '@tcpsystems/ui/foundation/Rating';
const uid = $props.id();
let score = $state(8);
</script>
<form onchange={(event) => score = Number((event.target as HTMLInputElement).value)}>
<Rating label="How likely are you to recommend Studio?" name={uid} max={10} value={score} />
</form>API
import Rating from '@tcpsystems/ui/foundation/Rating';| Prop | Type | Default |
|---|---|---|
label | string | none |
name | string | none |
max? | number | 5 |
value? | number | none |
readonly? | boolean | false |
| Hook | Kind |
|---|---|
.tcp-rating | Root class |
data-filled | Data attribute |