New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-star-rate

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-star-rate

Lightweight, customizable star ratings component for React

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
increased by20.04%
Maintainers
1
Weekly downloads
 
Created
Source

React Star Rate

NPM Version minzipped size Build Status

Lightweight, customizable star ratings component for React.

Created by Raymon Zhang

Features

  • 🔩 Easily Customizable
  • 🕊 Lightweight - less than 4kb including styles
  • Accessible

Table of contents

Installation

With yarn
yarn add react-star-rate
With NPM
npm install react-star-rate

Getting Started

You can add React Stars Rating to your project using the <StarsRating /> component.

import { useState } from 'react';

import StarsRating from 'react-star-rate';

const App = () => {
  const [value, setValue] = useState(0);
  return (
    <div>
      <StarsRating
        value={value}
        onChange={value => {
          setValue(value);
        }}
      />
    </div>
  );
};

Props

NameTypeDefaultDescription
allowClearbooleantrueAllow the value to be reset when clicked again
allowHalfbooleantrueSupport half of the star to be selected
autoFocusboolean-Automatically focus the element
classNamePrefixstring"react-star-rate"The components will have classNames with the given prefix
countnumber5Number of stars
defaultValuenumber0The default value of the stars. Should be the same as the default useState value
directionstring"ltr"The direction of the selected stars. Either "ltr" or "rtl"
disabledbooleanfalseDisable the rating element
onBlurfunction-Will be triggered on blur
onChangefunction(value) => {}Will be triggered on change of value
onFocusfunction-Will be triggered on focus
onHoverChangefunction(value) => {}Will be triggered on hover
styleobject{}Custom styles
symbolstring"★"The symbol to be displayed
tabIndexnumber0The tab index of the stars container
valuenumber-Controlled value of the component

Example

You can visit the example here: https://codesandbox.io/s/react-star-rate-okxlw.

Keywords

FAQs

Package last updated on 21 May 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc