
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
star-rating-react-ts
Advanced tools
A super simple, customizable star rating React component built with Typescript
Working examples can be found here Star Rating Examples
Requirements:
React >= 16.8.0
Install:
On the command line navigate to the project root and enter
npm install star-rating-react-ts
Import:
import {StarRating} from 'star-rating-react-ts'
JSX:
<YourComponent>
<StarRating/>
</YourComponent>
prop name | type | default | optional | description |
---|---|---|---|---|
numStars | number | 5 | true | number of stars to display |
initialRating | number | 0 | true | initial rating value |
readOnly | boolean | false | true | ignore user interaction |
theme | object | see below | true | styling options |
onClick | function | undefined | true | called when the user clicks a star, receives the new star rating as an argument (number) |
icon | JSX.Element | undefined | true | a custom SVG icon imported as a React Component |
Schema and default values for the theme prop object (all properties are optional):
{
colors: {
backgroundDefault: 'lightgray',
backgroundColorActive: '#D8A127',
backgroundColorHover: '#275ed8'
}
},
size: 50
}
By default the star rating component displays a star icon SVG. To use a custom icon in the star rating:
src
folder within the project root:App.tsx
// Using Create React App
import { ReactComponent as BoneIcon } from './assets/bone.svg';
// Using the SVGR plugin for Vite
import BoneIcon from "./assets/bone.svg?react";
function App () {
...
return <StarRating icon={<BoneIcon/>}/> // <-- pass custom icon as a component!
}
<svg>
tag to ensure the theme colors and size props are inherited.bone.svg
<svg xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
width="100%"
...
</svg>
In addition to standard mouse and touch events this component is designed to be compatible with assistive technology (ie screen readers) and keyboard navigation. We use Axe Dev Tools to test for accessibility.
FAQs
A super simple, customizable star rating React component built with Typescript
We found that star-rating-react-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.