Socket
Socket
Sign inDemoInstall

react-custom-rating-component

Package Overview
Dependencies
3
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-custom-rating-component

A fully customizable rating component for react and next.js


Version published
Weekly downloads
46
decreased by-20.69%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

PropTypeDefaultDescription
defaultValuestring0Required. This is the value of the rating displayed by default. Supply this if your rating is also a readOnly
precisionnumber1The value to increment rating when hovered or clicked
countnumber5The number of Icons to display
shapestar or heartstarThis is the shape displayed as icon
onChangefunction-This is the function that is called when the rating value changes
onHoverfunction-This is the function that is called when the rating Icon is hovered
classNamestring''classes passed to the parent component
readOnlybooleanfalseThis sets the component to be non editable
sizestring24pxThis defines the size of the Icons used
spacingstring5pxThis defines the fap between the Icons used
activeColorstringorangeThis is the color of the icon in the active state
defaultColorstringgrayThis is the color of the icon in the inactive state
titleArraystring[]['Poor', 'Good', 'Very Good', 'Best', 'Excellent']These are displayed as titles when icons are hovered
showTitlebooleanfalseThis 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.

Keywords

FAQs

Last updated on 30 Aug 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc