- Prop
value- Type
number | undefined- Default
- —
- Requirement
- optional
Docs Components Commerce
Rating
React example follows below.
Vue example follows below.
Angular example follows below.
Svelte example follows below.
Solid example follows below.
- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import * as React from "react";const ratingFixture = { id: "rating", value: 4, label: "Rate this trowel", readOnlyValue: 4.5, readOnlySize: "sm",} satisfies { id: string; value: number; label: string; readOnlyValue: number; readOnlySize: "sm" | "md" | "lg";}; import { Rating } from "@grassroot/ui-react"; export default function RatingDemo() { const [value, setValue] = React.useState(ratingFixture.value); return ( <div> <Rating value={value} onChange={setValue} label={ratingFixture.label} /> <Rating value={ratingFixture.readOnlyValue} readOnly size={ratingFixture.readOnlySize} /> </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">import { ref } from "vue";const ratingFixture = { id: "rating", value: 4, label: "Rate this trowel", readOnlyValue: 4.5, readOnlySize: "sm",} satisfies { id: string; value: number; label: string; readOnlyValue: number; readOnlySize: "sm" | "md" | "lg";}; import { Rating } from "@grassroot/ui-vue"; const value = ref(ratingFixture.value);</script> <template> <div> <Rating v-model="value" :label="ratingFixture.label" /> <Rating :model-value="ratingFixture.readOnlyValue" read-only :size="ratingFixture.readOnlySize" /> </div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component, signal } from "@angular/core";const ratingFixture = { id: "rating", value: 4, label: "Rate this trowel", readOnlyValue: 4.5, readOnlySize: "sm",} satisfies { id: string; value: number; label: string; readOnlyValue: number; readOnlySize: "sm" | "md" | "lg";}; import { GrassrootRating } from "@grassroot/ui-angular"; @Component({ selector: "app-rating-demo", standalone: true, imports: [GrassrootRating], template: ` <div> <grassroot-rating [value]="value()" (valueChange)="value.set($event)" [label]="fixture.label" /> <grassroot-rating [value]="fixture.readOnlyValue" [readOnly]="true" [size]="fixture.readOnlySize" /> </div> `,})export class RatingDemoComponent { protected readonly fixture = ratingFixture; readonly value = signal(ratingFixture.value);} export default RatingDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> import { Rating } from "@grassroot/ui-svelte"; const ratingFixture = { id: "rating", value: 4, label: "Rate this trowel", readOnlyValue: 4.5, readOnlySize: "sm", } satisfies { id: string; value: number; label: string; readOnlyValue: number; readOnlySize: "sm" | "md" | "lg"; }; let value = $state(ratingFixture.value);</script> <div> <Rating {value} onChange={(next) => (value = next)} label={ratingFixture.label} /><Rating value={ratingFixture.readOnlyValue} readOnly size={ratingFixture.readOnlySize} /></div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */import { createSignal } from "solid-js";import { Rating } from "@grassroot/ui-solid";const ratingFixture = { id: "rating", value: 4, label: "Rate this trowel", readOnlyValue: 4.5, readOnlySize: "sm",} satisfies { id: string; value: number; label: string; readOnlyValue: number; readOnlySize: "sm" | "md" | "lg";}; export default function RatingDemo() { const [value, setValue] = createSignal(ratingFixture.value); return ( <div> <Rating value={value()} onChange={setValue} label={ratingFixture.label} /> <Rating value={ratingFixture.readOnlyValue} readOnly size={ratingFixture.readOnlySize} /> </div> );}Installation
API Reference
Import
import * as React from "react";
import { Rating } from "@grassroot/ui-react";
Props
Prop
Type
Default
Requirement
valuenumber | undefined—
optional
defaultValuenumber | undefined—
optional
maxnumber | undefined—
optional
readOnlyboolean | undefined—
optional
onChange((value: number) => void) | undefined—
optional
size"sm" | "md" | "lg" | undefined—
optional
labelstring | undefined—
optional
classNamestring | undefined—
optional
- Prop
defaultValue- Type
number | undefined- Default
- —
- Requirement
- optional
- Prop
max- Type
number | undefined- Default
- —
- Requirement
- optional
- Prop
readOnly- Type
boolean | undefined- Default
- —
- Requirement
- optional
- Prop
onChange- Type
((value: number) => void) | undefined- Default
- —
- Requirement
- optional
- Prop
size- Type
"sm" | "md" | "lg" | undefined- Default
- —
- Requirement
- optional
- Prop
label- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
className- Type
string | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onChange | ((value: number) => void) | undefined |
Import
import { ref } from "vue";
import { Rating } from "@grassroot/ui-vue";
Props
Prop
Type
Default
Requirement
modelValuenumber | undefined0optional
maxnumber | undefined5optional
readOnlyboolean | undefinedtrueoptional
size"sm" | "md" | "lg" | undefined"md"optional
labelstring | undefined"Rating"optional
- Prop
modelValue- Type
number | undefined- Default
0- Requirement
- optional
- Prop
max- Type
number | undefined- Default
5- Requirement
- optional
- Prop
readOnly- Type
boolean | undefined- Default
true- Requirement
- optional
- Prop
size- Type
"sm" | "md" | "lg" | undefined- Default
"md"- Requirement
- optional
- Prop
label- Type
string | undefined- Default
"Rating"- Requirement
- optional
Events
| Event | Payload |
|---|---|
update:modelValue | [value: number] |
Import
import { Component, signal } from "@angular/core";
import { GrassrootRating } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
valuenumber0optional
maxnumber5optional
readOnlybooleantrueoptional
size"sm" | "md" | "lg""md"optional
labelstring"Rating"optional
- Prop
value- Type
number- Default
0- Requirement
- optional
- Prop
max- Type
number- Default
5- Requirement
- optional
- Prop
readOnly- Type
boolean- Default
true- Requirement
- optional
- Prop
size- Type
"sm" | "md" | "lg"- Default
"md"- Requirement
- optional
- Prop
label- Type
string- Default
"Rating"- Requirement
- optional
Events
| Event | Payload |
|---|---|
valueChange | number |
Import
import { Rating } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
valuenumber—
optional
defaultValuenumber0optional
modelValuenumber—
optional
maxnumber5optional
readOnlybooleantrueoptional
size"sm" | "md" | "lg""md"optional
labelstring"Rating"optional
onChange(value: number) => void—
optional
classNamestring—
optional
- Prop
value- Type
number- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
number- Default
0- Requirement
- optional
- Prop
modelValue- Type
number- Default
- —
- Requirement
- optional
- Prop
max- Type
number- Default
5- Requirement
- optional
- Prop
readOnly- Type
boolean- Default
true- Requirement
- optional
- Prop
size- Type
"sm" | "md" | "lg"- Default
"md"- Requirement
- optional
- Prop
label- Type
string- Default
"Rating"- Requirement
- optional
- Prop
onChange- Type
(value: number) => void- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onChange | (value: number) => void |
Import
import { createSignal } from "solid-js";
import { Rating } from "@grassroot/ui-solid";
Props
Prop
Type
Default
Requirement
valuenumber—
optional
defaultValuenumber0optional
maxnumber5optional
readOnlybooleantrueoptional
onChange(value: number) => void—
optional
size"sm" | "md" | "lg""md"optional
labelstring"Rating"optional
classNamestring—
optional
- Prop
value- Type
number- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
number- Default
0- Requirement
- optional
- Prop
max- Type
number- Default
5- Requirement
- optional
- Prop
readOnly- Type
boolean- Default
true- Requirement
- optional
- Prop
onChange- Type
(value: number) => void- Default
- —
- Requirement
- optional
- Prop
size- Type
"sm" | "md" | "lg"- Default
"md"- Requirement
- optional
- Prop
label- Type
string- Default
"Rating"- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onChange | (value: number) => void |