Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lite-react-rating

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lite-react-rating

A Lite React component for rating stars

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
0
Weekly downloads
 
Created
Source

lite-react-rating

A customizable React component for displaying star ratings.

Installation

Install the package using npm:

npm install lite-react-rating

Or with yarn:

yarn add lite-react-rating

Peer Dependencies Ensure you have react and react-dom installed in your project:

npm install react react-dom

Usage

Import the RatingHandler component and use it in your React application.

TypeScript Support

Type definitions are included with the package, allowing seamless integration in TypeScript projects.

Author

Mais Aburabie

Basic Example

import RatingHandler from 'lite-react-rating';

const App = () => {

  return (
    <div>
      <h1>Product Rating</h1>
      <RatingHandler value={3} readOnly={true} dir="ltr"/>
    </div>
  );
};

export default App;

Props

value (required)

  • Type: number
  • Description: The current rating value.

onChange

  • Type: (value: number) => void
  • Description: Callback function called when the rating changes.

readOnly

  • Type: boolean
  • Default: false
  • Description: If true, the rating component is read-only.

max

  • Type: number
  • Default: 5
  • Description: The maximum number of stars to display.

dir

  • Type: ltr | rtl
  • Default: ltr
  • Description: The Direction of stars to display.

Advanced Example

Here's a more detailed example demonstrating all available props:


import React, { useState } from 'react';
import RatingHandler from 'lite-react-rating';

const ProductReview = () => {
  const [rating, setRating] = useState(0);

  const handleRatingChange = (value) => {
    console.log('Selected rating:', value);
    setRating(value);
  };

  return (
    <div>
      <h2>Rate Our Product</h2>
      <RatingHandler
        value={rating}
        onChange={handleRatingChange}
        readOnly={false}
        dir="ltr"
        max={10}
      />
      <p>Your rating: {rating}</p>
    </div>
  );
};

export default ProductReview;


License

This project is licensed under the ISC License.

Keywords

FAQs

Package last updated on 04 Oct 2024

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