0.1.4 • Published 11 months ago

react-simple-star-ratings v0.1.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

React Simple Rating Package

A simple npm package for Different Types of Rating to your project.

NPM JavaScript Style Guide GitHub

Install

  • npm
npm i react-simple-star-ratings
  • Import the package in your app:
import {StarRating} from 'react-simple-star-ratings';
  • Get the Component from the package
<StarRating /*Availabe Props*//>
<TagStarRating /*Availabe Props*/ />

Usage

import React from 'react'
import {StarRating} from 'react-simple-star-ratings';
import './App.css'

function App() {
  const starArray = [1, 2, 3, 4, 5];

  const starArrayTag = [
    { st: 1, tag: "Terrible" },
    { st: 2, tag: "Bad" },
    { st: 3, tag: "Average" },
    { st: 4, tag: "Great" },
    { st: 5, tag: "Awesome" },
  ];

  return (
    <>
      <h1>Star Rating in React</h1>
      <StarRating tooltipArray={starArray} />

      <TagStarRating
        allowTitleTag={true}
        tooltipDefaultText
        tooltipArray={starArrayTag}
      />

      // There are Different Types of React Components
      // Availave in the Demo please Visit !!!
    </>
  )
}

export default App;

Available Props

PropTypeOptionsDescriptionDefault
onClickfunctionOptionalcallback with hover, index and event values passed-
onMouseOverfunctionOptionalcallback with event passed-
onMouseLeavefunctionOptionalcallback with event passed-
initialValuenumberOptionalSet initial value0
iconsCountnumberOptionalNumber of the icons5
transitionbooleanOptionalAdds a smooth transition effect on mouse hoverfalse
classNamestringOptionalApplied to the main spanreact-simple-star-rating
styleCSSPropertiesOptionalInline style applied to the main spanbasic style
emptyStyleCSSPropertiesOptionalInline style applied to empty icon spanbasic style
emptyClassNamestringOptionalApplied to the empty icon spanempty-icons
customIconsarray of objectOptionalAdd a group of icons[]
allowHoverbooleanOptionalEnable / Disable hover effecttrue
disableFillHoverbooleanOptionalEnable / Disable hover effect on filled starsfalse
allowTitleTagbooleanOptionalEnable / Disable HTMLtitle Tagtrue
showTooltipbooleanOptionalShow a tooltip with live valuesfalse
tooltipDefaultTextstringOptionalInitial tooltip text if no rating valueYour Rate
tooltipArrayarrayOptionalArray of strings to show inside tooltip[]
tooltipClassNamestringOptionalTooltip CSS classrating-tooltip

Demo

React Simple Star Ratings.


License

Apache License 2.0 © SURAJPATIL6088

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago