Rate

free

Rate captures a star or symbol score for reviews, feedback, and quality ratings.

How was your experience?

Your rating helps us improve future orders.

3 out of 5
import { useState } from 'react';
import Rate from '@/components/ui/rate';

export default function UsageDemo() {

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Rate

Examples

Basic

import Rate from '@/components/ui/rate';

export default function BasicDemo() {
  return <Rate defaultValue={3} />;

Half Ratings

3.5 stars
import { useState } from 'react';
import Rate from '@/components/ui/rate';

export default function HalfRatingsDemo() {

Count

import Rate from '@/components/ui/rate';

export default function CountDemo() {
  return <Rate count={10} defaultValue={7} />;

Custom Character

import Rate from '@/components/ui/rate';
import { PiHeart } from 'react-icons/pi'

const sentiments = ['Poor', 'Fair', 'Good', 'Very Good', 'Excellent'];

States

Read only
4.0 average
Disabled
import Rate from '@/components/ui/rate';

export default function StatesDemo() {
  return (

Controlled

Current rating: 2
import { useState } from 'react';
import Rate from '@/components/ui/rate';
import Button from '@/components/ui/button';

API

Rate renders a single div with role="slider" and full keyboard support: arrow keys adjust the value by one step, and Home / End jump to the minimum and maximum.

PropDescriptionTypeDefault
valueCurrent rating for controlled usage.number-
defaultValueInitial rating for uncontrolled usage.number0
countNumber of rating items rendered.number5
allowHalfEnables half-step precision by splitting each item into two halves.booleanfalse
allowClearClicking the current value again resets the rating to 0.booleantrue
disabledDims the control and blocks all interaction.booleanfalse
readOnlyDisplays the value at full opacity but blocks interaction.booleanfalse
nameRenders a hidden input so the value submits with a native form.string-
characterCustom rating symbol, either a node or a render function per item.RateCharacterStarIcon
tooltipsNative title text per item, indexed from the first item.string[]-
labelTrailing content rendered after the last item, such as a live readout.ReactNode-
sizeControl size.ControlSize'md'
classNamesClass name overrides for the item, icon, and label slots.RateClassNames-
onChangeCalled with the next value when the rating is committed.(value: number) => void-
onHoverChangeCalled with the previewed value as the pointer moves across items.(value: number) => void-
classNameClass names applied to the root element.string-
refRef forwarded to the root div.Ref<HTMLDivElement>-
...nativeDivPropsNative props for the root div.NativeRateDivProps-

Types

type ControlSize = 'sm' | 'md' | 'lg';
 
type RateCharacter =
  | ReactNode
  | ((props: {
      index: number;
      value: number;
      active: boolean;
    }) => ReactNode);
 
type RateClassNames = {
  item?: string;
  icon?: string;
  label?: string;
};
 
type NativeRateDivProps = Omit<
  ComponentPropsWithRef<'div'>,
  'children' | 'onChange'
>;