Anex UI logoAnex UI
npm install anexui
Documentation

Documentation

Rating

Star rating with full, half, and empty states — interactive or read-only.

Preview

Interactive — selected:
Read-only — 3.5 stars with half
sm
md
lg
Disabled

Usage

import { useState } from "react";
import { Rating } from "anexui";

function Example() {
  const [stars, setStars] = useState(0);
  return (
    <Rating value={stars} onChange={setStars} />
  );
}
Copy code

Half stars

Enable allowHalf to let users select 0.5-step values.

<Rating value={3.5} onChange={setStars} allowHalf />
Copy code

Read-only

<Rating value={4.5} readOnly allowHalf />
Copy code

Sizes

<Rating value={4} readOnly size="sm" />
<Rating value={4} readOnly size="md" />
<Rating value={4} readOnly size="lg" />
Copy code

Disabled

<Rating defaultValue={3} disabled />
Copy code

Props

| Prop | Type | Default | Description | |---|---|---|---| | value | number | — | Controlled rating value | | defaultValue | number | 0 | Initial value (uncontrolled) | | onChange | (value: number) => void | — | Called when the user changes the rating | | max | number | 5 | Total number of stars | | allowHalf | boolean | false | Allow half-star selections | | readOnly | boolean | false | Disables interaction; keeps hover effects off | | disabled | boolean | false | Disables interaction and applies muted styles | | size | "sm" \| "md" \| "lg" | "md" | Star size | | className | string | — | Extra class names on the root element | | label | string | — | aria-label for screen readers |