npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-custom-rating-component

v0.1.6

Published

A fully customizable rating component for react and next.js

Downloads

1,599

Readme

A fully customizable custom react rating component

Customizable react star ratings. It allows use of different precisions and supports custom icon like heart icon

npm install react-custom-rating-component

Or

yarn add react-custom-rating-component

Motivation

I wanted a star rating component that was highly customizable and could do half stars, and I wanted it to be declarative. I couldn't find one that I liked, so I made one.

Demo

Check out the playground with different use cases Play Ground

Take a look at react-custom-rating-component live example

Demo Example Image

Usage

import { Rating } from 'react-custom-rating-component'

const App = () => {
  return (
    <div
      style={{
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        margin: '40px 20px',
      }}
    >
      <Rating
        defaultValue={2.5}
        size='30px'
        spacing='10px'
        activeColor='red'
        onChange={(newRating) => console.log('newRating', newRating)}
        onHover={(hoveredRating) => console.log('hoveredRating', hoveredRating)}
      />
    </div>
  )
}

All Props

| Prop | Type | Default | Description | | :------------- | :------------ | :------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------- | | defaultValue | string | 0 | Required. This is the value of the rating displayed by default. Supply this if your rating is also a readOnly | | precision | number | 1 | The value to increment rating when hovered or clicked | | count | number | 5 | The number of Icons to display | | shape | star or heart | star | This is the shape displayed as icon | | onChange | function | - | This is the function that is called when the rating value changes | | onHover | function | - | This is the function that is called when the rating Icon is hovered | | className | string | '' | classes passed to the parent component | | readOnly | boolean | false | This sets the component to be non editable | | size | string | 24px | This defines the size of the Icons used | | spacing | string | 5px | This defines the fap between the Icons used | | activeColor | string | orange | This is the color of the icon in the active state | | defaultColor | string | gray | This is the color of the icon in the inactive state | | titleArray | string[] | ['Poor', 'Good', 'Very Good', 'Best', 'Excellent'] | These are displayed as titles when icons are hovered | | showTitle | boolean | false | This defines whether to display the titles or not |

Browser Support

This library is supported by all the major browsers. If you find any issues please raise an issue on the repo and I will attend to it as soon as possible.

Contribute

If you have any ideas on how to make this library better, please feel free to contribute by raising a PR or an issue. I will be happy to review and merge.