1.2.0 • Published 2 months ago

vue-rating-input v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

Vue Rating Input ⭐⭐⭐⭐⭐

npm

Description

A simple and easy to use Vue package that allows the use of a star rating field to use with your forms. ⭐⭐⭐⭐⭐

This package is created using the Vue3 framework and the typescript language

Install

Available via npm

npm install vue-rating-input

See it in action

Examples here

Usage

Load and use vueRatingInput component.

Script

<script setup>
  import vueRatingInput from 'vue-rating-input'

  import { ref } from 'vue'

  const value = ref()
</script>

Script using Typescript

<script setup lang="ts">
  import vueRatingInput from 'vue-rating-input'

  import { ref, Ref } from 'vue'

  const value:Ref<number | undefined> = ref()
</script>

Template

Using v-model

<template>
    <RatingInput v-model="value" />
</template>

Using event callback

<template>
    <RatingInput :modelValue="value" @update:modelValue="value = $event" />
</template>

and import CSS on your main.js

import "vue-rating-input/dist/style.css";

Props

{
    numberOfStars: {
        type: Number,
        default: 5,
        validator: Must be between 2 and 10
        description: Number of starts to display
    },
    color: {
        type: CssColor,
        default: '#ffb74b',
        description: Color of star icon
    },
    size: {
        type: CssSize,
        default: '2rem',
        description: CSS size of star icon
    },
    readonly: {
        type: Boolean,
        default: false,
        description: Allows you to distinguish between editable mode and reading mode
    },
    modelValue: {
        type: Number,
        default: undefined,
        description: Default value of the input
    },
}

Slots

Two slots are available for this component:

  • After: allows you to add content before the stars. It will be useful to define your labels.
  • Before: allows you to add content after the stars. it will be useful to add content such as the average grades in the case of reading mode (readonly = true) for example.
<template>
    <RatingInput>
        <template #before>
            <label>Leave your rating</label>
        </template>
    </RatingInput>

    <RatingInput readonly>
        <template #after>
            <label>Rating is 4,75</label>
        </template>
    </RatingInput>
</template>
1.2.0

2 months ago

1.1.0

7 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago