π₯ 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)