DEV Community

Cover image for Introducing react-number-rating โ€“ A 1โ€“10 React Rating Component for Better UI
Raj Kumar
Raj Kumar

Posted on

Introducing react-number-rating โ€“ A 1โ€“10 React Rating Component for Better UI

๐Ÿ”ฅ Introduction

โ€œThe react-number-rating component helps you add clean, user-friendly numeric rating systems (1โ€“10) in React apps with minimal setup.โ€

If you're building a feedback form, product rating, or any kind of review system in a React app, youโ€™ve probably used stars, sliders, or emojis. But what if you want something more precise, clean, and customizable?

Introducing react-number-rating โ€” a modern and developer-friendly rating component for React that displays a numeric scale from 1 to 10, with optional color coding to visually represent the score strength.

๐Ÿ”— Live Demo

๐Ÿ‘‰ Try it on CodeSandbox

โœจ Features

โœ… Numeric scale from 1 to 10
โœ… Custom color for each number
โœ… Easily style via props or CSS
โœ… Lightweight โ€“ no external styling libraries
โœ… Built with React 17/18 compatibility
โœ… Perfect for feedback forms, review UIs, or product ratings

๐Ÿ“ฆ Installation

Install via NPM:

npm install react-number-rating

๐Ÿ› ๏ธ Usage Example

import React, { useState } from "react";
import PriorityRating from "react-number-rating";

export default function App() {
  const [priority, setPriority] = useState(5);
  return (
    <PriorityRating
      max={10}
      value={priority}
      name="priority"
      onChange={(val) => setPriority(val)}
    />
  );
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก Tip: The onChange callback lets you hook into form logic easily.

โš™๏ธ Props Breakdown

Prop Type Description
value number The current rating value (1โ€“10)
onChange func Callback function when a rating is selected
activeColor string Color of selected rating numbers (default: #1976d2)
inactiveColor string Color of unselected numbers (default: #e0e0e0)
size string Size of the number buttons (small, medium, large)

๐ŸŽฏ Real-World Use Cases

  • User feedback forms
  • Product reviews
  • Quiz or exam grading UI
  • Habit tracking (e.g., rate your productivity)

๐Ÿง‘โ€๐Ÿ’ป About the Author

Iโ€™m Rajkumar, a passionate frontend engineer focused on building modular and reusable UI solutions. This is part of my effort to help developers quickly ship polished user experiences in React.

๐Ÿ‘‰ GitHub
๐Ÿ‘‰ Buy Me a Coffee

๐Ÿ’– Support the Project

If you find this useful, consider supporting me:

โญ Star the repo on GitHub

๐Ÿง‘โ€๐Ÿ’ป Try it in your next React project

๐Ÿ’ธ Sponsor via GitHub

โ˜• Buy Me a Coffee

๐Ÿ“Œ Final Thoughts

react-number-rating is a tiny but powerful component that brings numeric clarity to user ratings in React apps. Whether you're building SaaS, dashboards, or mobile-first apps, it's plug-and-play ready.

Have suggestions or want to contribute? PRs are always welcome!

Top comments (0)