1.0.4 • Published 1 year ago

react-ts-rating-star v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago