shaf-rate

Accessible star rating element. Upgrades <input type="number" />

Usage no npm install needed!

<script type="module">
  import shafRate from 'https://cdn.skypack.dev/shaf-rate';
</script>

README

It's easy peasy

Keyboard accessible. Check out the demo. Works in IE11, Edge, Chrome, Firefox, and Safari.

<!-- Custom Elements v1 polyfill (2.7KB gzipped) -->
<script src="https://unpkg.com/@webcomponents/custom-elements@1.0.0-alpha.3"></script>
<!-- Our custom element's source -->
<script src="https://unpkg.com/shaf-rate@0.0.5"></script>

Usage

<shaf-toggle>
  <input type="number" min="1" max="10" step="0.5" value="5" />
</shaf-toggle>

Benefits

Because this wraps an existing <input type="number" />:

  • It is form-friendly.
  • It doesn't mess with your event handlers.
  • Your checkbox still works if JavaScript is turned off or fails to load.