๐ฅ 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
โจ 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)}
/>
);
}
๐ก 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)