![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@rubenvara/react-star-rating
Advanced tools
A simple React component that shows a rating from 0 to 5 with svg stars when passed a number
A simple React component that shows a rating from 0 to 5 with svg stars. Just need to pass a number. No dependencies required.
As with any other node package in React, Gatsby, Next.js, etc.:
npm i @rubenvara/react-star-rating
The package exports a React component.
The component takes a number of props:
Prop | Type | Default | Required | Description |
---|---|---|---|---|
rating | Number | - | Yes | The rating. Any number from 0 to 5.0 |
config | Object | {} | No | Config options for the component. See below |
style | Object | {} | No | CSS styles passed directly to the container component |
About the config object:
Option | Type | Default | Description |
---|---|---|---|
fullColor | String | '#ffcf00' | The color for the filling of the stars |
emptyColor | String | '#7f7f7f' | The color for the empty parts of the stars |
size | Number | 20 | The size of the stars. Pass a number of pixels. |
showText | Boolean | false | Show the rating number next to the stars or not |
About the style prop: It accepts an object of css styles, written in camelCase to inline in JSX components. It is passed directly, unchecked, to the main div
. Use it cautiously. Check the example below.
config.showText = true
), font size is half the star size or 16px, whichever is higher.Use it as follows:
import StarRating from '@rubenvara/react-star-rating';
// ...
return <StarRating rating={3.35} />;
// ...
Output:
import StarRating from '@rubenvara/react-star-rating';
// ...
const rating = 3.35;
const config = {
fullColor: '#f05',
emptyColor: 'hsl(240, 80%, 85%)',
size: 42,
showText: true,
};
const style = {border: `1px solid`, borderColor: `firebrick`, padding: 12};
// ...
return <StarRating rating={rating} config={config} style={style} />;
//...
Output:
[1.0.1] - 2020-12-10
FAQs
A simple React component that shows a rating from 0 to 5 with svg stars when passed a number
We found that @rubenvara/react-star-rating 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.