Socket
Socket
Sign inDemoInstall

react-ts-rating-star

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-ts-rating-star

React TS Rating Star allows you to create a customizable rating star component with ease.


Version published
Weekly downloads
10
decreased by-47.37%
Maintainers
1
Install size
20.1 kB
Created
Weekly downloads
 

Readme

Source

React TS Rating Star

React TS Rating Star allows you to create a customizable rating star component with ease.

How to use

Requirements:

React >= 16.8.0

Installation:

On the command line navigate to the project root and enter:

npm install react-ts-rating-star
yarn add react-ts-rating-star

TSX:

import { RatingStar } from 'react-ts-rating-star'

// ...

<RatingStar />

Props

Prop nameTypeDefaultOptionalDescription
numberOfStarsnumber5trueThe number of stars to display.
averageRatingnumbertrueThe rate displayed before interacting with the component.
iconColorstring'gold'trueThe color of the icons when active.
backgroundColorstring'darkgray'trueThe background color of the icons (inactive icon.)
iconWidthstring'2em'trueThe width of the icons.
iconHeightstring'2em'trueThe height of the icons.
iconHoverEffectHoverEffect'none'trueThe effect on hover (see HoverEffect type below).
onClick(rating: number) => unknowntrueFunction called when the user clicks on a star.

HoverEffect

Possible values of iconHoverEffect are the following:

'none'
'scaling'
'twinkling'
'rotating'
'animated-scaling'
'animated-twinkling'
'animated-rotating'

Example

import React from 'react'
import { RatingStar } from 'react-ts-rating-star'
import MyCustomIcon from './MyCustomIcon.tsx'

const ExampleRatingStar = () => {
  const getStarNumberClicked = (rating: number) => {
    console.log(`Rating: ${rating}`)
  }

  return (
    <RatingStar
      iconColor='#fdcb6e'
      backgroundColor='#dfe6e9'
      iconWidth='4em'
      iconHeight='4em'
      averageRating={3.81}
      iconHoverEffect='scaling'
      onClick={getStarNumberClicked}
    />
  )
}

export default ExampleRatingStar

Keywords

FAQs

Last updated on 01 Apr 2024

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