Rating API

API documentation for Rating component

Rating#

Props#

Defines valid properties in Rating component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: RatingInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: RatingInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<RatingPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: RatingInstance) => ReactNode)
null
The children to render.
namestring
null
Name of the element.
invalidboolean
false
When present, it specifies that the component should have invalid state style.
valuenumber
null
Value of the rating.
defaultValuenumber
null
The default value for the input when not controlled by `modelValue` .
allowHalfboolean
true
Whether to allow half stars.
starsnumber
5
Number of stars.
disabledboolean
false
When present, it specifies that the element should be disabled.
readOnlyboolean
false
When present, it specifies that component is read-only.
onValueChange(event: useRatingChangeEvent) => void
null
Callback function that is called when the value changes.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in Rating component.

nametypedefaultdescription
valuenumber
null
The value of the rating.
hoverValuenumber
null
The hover value of the rating.
focusedOptionIndexnumber
null
The focused option index of the rating.
isFocusVisibleItemboolean
null
Whether the focus is visible item of the rating.

Exposes#

Defines the methods and properties exposed by Rating component.

nametypedefaultdescription
stateuseRatingState
null
Current state of the rating.
getOptionState(value: number) => string
null
Get the state of a star.
onInputFocus(event: FocusEvent<HTMLInputElement>) => void
null
Handle input focus event.
onInputBlur(event: FocusEvent<HTMLInputElement>) => void
null
Handle input blur event.
onInputChange(event: ChangeEvent<HTMLInputElement>) => void
null
Handle input change event.
onOptionClick(event: MouseEvent<HTMLDivElement>, value: number) => void
null
Handle option click event.
onOptionHover(event: PointerEvent<HTMLDivElement>, value: number) => void
null
Handle option hover event.

Interfaces#

Defines passthrough(pt) options of Rating component.

nametypedefaultdescription
rootRatingPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of Toolbar component.

values
ComponentInstance<RatingProps, RatingState, RatingExposes>