Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Rating

rating

Captures a controlled rating with radio semantics, custom icons, and hover preview.

Usage

Basic usage

Uncontrolled default 3 stars, click/hover to change points; when controlled use value + onValueChange.

tsx
<Rating defaultValue={3} onValueChange={setValue} />

Read only

readOnly Only displays ratings, no interaction.

tsx
<Rating value={4} readOnly />

Size

size controls the icon size (sm / md / lg).

tsx
<>
  <Rating defaultValue={3} size="sm" />
  <Rating defaultValue={3} size="md" />
  <Rating defaultValue={3} size="lg" />
</>

Custom color

color accepts token var() or any CSS color, hover is automatically derived.

tsx
<Rating defaultValue={4} color="var(--color-warning)" />

Custom icon

icon accepts any icon, such as ❤️, and the empty state reuses the same shape.

tsx
<Rating
  defaultValue={3}
  color="var(--color-danger)"
  icon={<Heart size="1em" fill="currentColor" />}
/>

When to use

Use Rating to collect a star score or satisfaction level, or to show an existing score visually. Icons can be replaced with hearts, flames, or other symbols, while color-mix derives hover colors from the configured token. For a read-only view that only needs the numeric value, render text instead.

Import

ts
import { Rating } from "@hulianui/ui"

Props

NameTypeDefaultDescription
valuenumber-Controlled current score.
defaultValuenumber-Initial score when uncontrolled.
maxnumber5Maximum number of rating icons.
readOnlybooleanfalseShows a noninteractive rating.
disabledboolean-Disables interaction.
size"sm" | "md" | "lg""md"Icon size.
colorstringvar(--color-primary)Icon color as any CSS color or token variable; hover color is derived automatically.
classNamestring-Container class name

Events

EventTypeDescription
onValueChange(value: number | null) => voidCalled when the user selects a rating.

Slots

SlotTypeDescription
iconReactNodeCustom icon, such as <Heart /> (default solid five-pointed star)
emptyIconReactNodeCustomize the empty status icon, reuse the icon by default (same shape and empty color)

Example

tsx
const [v, setV] = useState<number | null>(3);
<Rating value={v ?? 0} onValueChange={setV} />

Read-only and custom icon/color:

tsx
<Rating value={4} readOnly />
<Rating defaultValue={3} color="var(--color-danger)" icon={<Heart size="1em" fill="currentColor" />} />

Usage guidelines

  • The callback is onValueChange, not the native onChange.
  • In readOnly mode, no radio inputs are rendered; only a static graphic with aria-label remains. Interactive mode uses real radio controls that can be selected by value.
  • Token colors must use the --color- prefix, for example var(--color-primary). Bare var(--primary) is not resolved; see [[hulian-token-color-var-needs-color-prefix]].
  • A custom icon needs fill="currentColor" to render as a solid shape, as shown above; otherwise only its stroke is colored.

Related

SecretField · Combobox · Listbox · Mentions · InputOTP · Upload

Playground

<Rating defaultValue={3} size="md" color="var(--color-primary)" />
PreviousInputOTPFormsNextUpload

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related
  • Playground