Rate
Star rating that displays any fractional score read-only, or lets users pick a value with pointer or keyboard.
import { Rate } from '@lobehub/ui/base-ui';Data Entry
Basic
Loading preview
APIs
Rate properties
allowHalfbooleanDefaults to
false.characternull | string | number | bigint | false | true | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode>colorstringcountnumberDefaults to
5.defaultValuenumberDefaults to
0.disabledbooleanDefaults to
false.gapnumberonChange(value: number) => voidreadOnlybooleanDefaults to
false.refnull | (instance: HTMLDivElement | null) => void | (() => VoidOrUndefinedOnly) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES] | RefObject<HTMLDivElement | null>Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).
sizenumberDefaults to
20.valuenumber
Also accepts all native HTML and ARIA attributes.
readOnly renders role="img" labelled like "4.3 out of 5" and fills any fraction proportionally. Interactive ratings are a role="slider": arrow keys step by 1 (or 0.5 with allowHalf), Home/End jump to 0 and count. gap defaults to half of size; empty stars use colorFill.
Migrating from antd Rate
- Display-only
disabled→readOnly;disablednow dims the control. charactertakes a node only;allowClear,tooltips,keyboardandautoFocusare not supported.- Size and colours are props (
size,color) instead ofConfigProvidertheme tokens.
Helpful?