0.0.7 • Published 1 year ago

@hbilal_9/vue3-star-ratings v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Vue Star Ratings

Vue 3 simple and customizable component for star ratings

Features

  • Simple to use
  • HTML Encode Characher Stars without quality loss
  • customize color, size, font-family, and counts of stars

Screenshots

App Screenshot

App Screenshot

Installation

Install Vue Stars Ratings with npm

  npm i @hbilal_9/vue3-star-ratings

Browser with CDN

<script src="https://unpkg.com/@hbilal_9/vue3-star-ratings/dist/index.js"></script>

Setup

Import Images Dragger in main.ts

  import StarRatings from '@hbilal_9/vue3-star-ratings'
  import '@hbilal_9/vue3-star-ratings/dist/style.css'
  app.use(StarRatings)

Use as component

  import StarRatings from '@hbilal_9/vue3-star-ratings'
  import '@hbilal_9/vue3-star-ratings/dist/style.css'

In template

  <star-ratings :starsCounts="7" v-model="ratings"></star-ratings>

you can also pass change event

  <star-ratings @star-change="getRatings"></star-ratings>

in script

function getRatings(e){
    console.log(e)
}

Usage

<script setup lang="ts">
  import { ref } from 'vue';
  const ratings = ref(0)

</script>

<template>
    <star-ratings v-model="ratings"></star-ratings>

    You added {{ ratings }} stars ratings.
</template>

Custom Style

You can pass a custom class as a props to design the component according to your needs

<star-ratings v-model="ratings" class="custom-style" />

css

.custom-style {
    color: red !important;
    font-size: 5rem !important;
    font-family: 'system-ui', 'Courier New', Courier, monospace;
}

Props

PropDescriptionTypeDefault
starsCountsStars countsNumber5
fillColorThis is the color of the stars when active or hoverString#ED8A19
sizestar size in accept px and remString3rem
fontFamilyThis is the font family of the stars,this will auto select accounding to your system's fontFamilyString'system-ui'

Support Me

support me to publish more packages like this for free.

Coffee