Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@rubenvara/react-star-rating
Advanced tools
Changelog
[1.0.1] - 2020-12-10
Readme
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:
FAQs
A simple React component that shows a rating from 0 to 5 with svg stars when passed a number
The npm package @rubenvara/react-star-rating receives a total of 11 weekly downloads. As such, @rubenvara/react-star-rating popularity was classified as not popular.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.