Socket
Socket
Sign inDemoInstall

thy-star-rating

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thy-star-rating

This is a simple star-rating web-component built with lit. It has a "value" attribute to set the initial value declarative.


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

ThyStarRating

This is a simple star-rating web-component built with lit. It has a "value" attribute to set the initial value declarative.

Screenshot

Features

  • small
  • lightweight
  • framework agnostic (like any other true web component)
  • integrates for example with vanilla, vue, react, angular, svelte, solid.js and many more
    <thy-star-rating></thy-star-rating>
    <thy-star-rating readonly></thy-star-rating> //readonly
    <thy-star-rating disabled></thy-star-rating> //disabled
    <thy-star-rating value="2"></thy-star-rating> // sets the initial Rating to 2 stars

It also fires a custom event "changed" when the rating is changed, that you can listen to like so:

 const els = document.querySelectorAll('thy-star-rating');
  els.forEach((el, idx) => {
    el.addEventListener('changed', (e) => {
      console.log(`Component ${idx + 1}: Rating changed from ${e.detail.oldValue} 🡒 ${e.detail.value}`);
    });
  });

Installation

npm install thy-star-rating

Usage

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My fancy app</title>
    <script type="module">import 'thy-star-rating';</script>
  </head>
  <body>
    <thy-star-rating></thy-star-rating>
  </body>
</html>

Attributes

nametypedefault-value
valuenumber (0-5)0
readonlybooleanfalse
disabledbooleanfalse

Styling

Overwrite colors with this css vars:

defaulthoverclickeddisabled
--star-default-color--star-halo-color--star-rated-color--star-disabled-color

Demo (or it didn't happen)

VISIT DEMO SITE

✨ Have Fun ! 🕺

Keywords

FAQs

Package last updated on 26 May 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