0.0.4 • Published 11 months ago

@danielgtmn/react-star-rating v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React Star Rating Component

npm version License: MIT TypeScript

A simple, customizable, and accessible star rating component for React applications.

📦 Installation

npm install @danielgtmn/react-star-rating
# or
yarn add @danielgtmn/react-star-rating
# or
pnpm add @danielgtmn/react-star-rating 

✨ Features

  • 🌟 Customizable number of stars (min/max)
  • 🎨 Custom colors and sizes
  • 🔄 Controlled and uncontrolled usage
  • ♿ Accessible
  • 🎯 TypeScript support
  • ✨ Hover effects

🚀 Quick Start

import { StarRating } from '@danielgtmn/react-star-rating';

function App() {
  return (
    <StarRating
      onChange={(rating) => console.log('New rating:', rating)}
      initialRating={3}
      size={32}
      activeColor="#FBBF24"
      inactiveColor="#D1D5DB"
      minStars={1}
      maxStars={10}
      showMinStarsText={true}
      showRatingText={true}
    />
  );
}

Props

PropTypeDefaultDescription
onChange(rating: number) => voidundefinedCallback function called when rating changes
initialRatingnumber0Initial rating value
sizenumber32Size of stars in pixels
activeColorstring'#FBBF24'Color of active (filled) stars
inactiveColorstring'#D1D5DB'Color of inactive stars
minStarsnumber1Minimum number of stars required
maxStarsnumber5Maximum number of stars available
showMinStarsTextbooleantrueShow/hide minimum stars requirement text
showRatingTextbooleantrueShow/hide current rating text

📋 Usage Examples

Basic Usage

<StarRating onChange={(rating) => console.log(rating)} />

Custom Range

<StarRating minStars={2} maxStars={10} />

Custom Colors

<StarRating
  activeColor="#FFD700"
  inactiveColor="#C0C0C0"
/>

Hide Texts

<StarRating
  showMinStarsText={false}
  showRatingText={false}
/>

Full Customization

<StarRating
  onChange={(rating) => console.log('New rating:', rating)}
  initialRating={3}
  size={32}
  activeColor="#FBBF24"
  inactiveColor="#D1D5DB"
  minStars={1}
  maxStars={10}
  showMinStarsText={true}
  showRatingText={true}
/>

📝 License

MIT

🤝 Contributing

Contributions are welcome! 1. Fork it 2. Create your feature branch (git checkout -b feature/amazing-feature) 3. Commit your changes (git commit -m 'Add some amazing feature') 4. Push to the branch (git push origin feature/amazing-feature) 5. Open a Pull Request

📫 Support

0.0.4

11 months ago

0.0.2

1 year ago