JGuang

Rate

Rate · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Rate

Graphical representation of the degree of rating scale.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Graphical representation of the degree of rating scale.

When to Use

Useful for showing things ratings and quick scoring.

Demos

Rate

Props

NameDescriptionTypeDefault
allowClearWhether to allow clearing after another click.booleantrue
allowHalfWhether to allow the selection of half.booleanfalse
characterCustom character.ReactNodeThe default star shape.
countTotal number of stars.number5
defaultValueThe default value of rate.number0
onChangeCallback when select.(value: number) => void-
readOnlyThe component is uninteractable when true.booleanfalse
valueThe value of rate.number-

CSS Variables

NameDescriptionDefault
--active-colorFill color when active.var(--adm-color-yellow)
--star-sizeStar size.24px
--inactive-colorFill color when inactive.var(--adm-color-border)
--inactive-color-halfFill color when inactive(half-selected mode - left half).var(--adm-color-border)