Need help with ngx-bar-rating?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

MurhafSousli
140 Stars 43 Forks MIT License 36 Commits 22 Opened issues

Description

Angular Bar Rating

Services available

!
?

Need anything else?

Contributors list

# 56,372
TypeScr...
HTML
iframe
share-b...
25 commits

Angular Bar Rating

Minimal, light-weight Angular ratings.

npm npm npm Build Status npm


Table of Contents

Installation

Install it with npm

npm i ngx-bar-rating

Basic usage:

Import

BarRatingModule
in the root module
import { BarRatingModule } from "ngx-bar-rating";

@NgModule({ imports: [ // ... BarRatingModule ] })

In your template


Rating options (inputs):

  • [rate]: Current rating. Can be a decimal value like 3.14, default

    undefined
    .
  • [max]: Maximal rating that can be given using this widget, default

    5
  • [readOnly]: A flag indicating if rating can be updated, default

    false
  • [theme]: Theme class. default

    default
    , see available themes.
  • [showText]: Display rating title if set, otherwise display rating value, default

    false
    .
  • [titles]: Titles array. array length should be equal to the

    max
    value, each index represents the rating title, default
    []
    .
  • [required]: A flag indicating if rating is required for form validation. default

    false
    .
  • [disabled]: A flag indicating if rating is disabled. works only with forms, default

    false
    .
  • (rateChange): An event fired when a user selects a new rating.

Event's payload equals to the newly selected rating.

  • (hover): An event fired when a user is hovering over a given rating.

Event's payload equals to the rating being hovered over.

  • (leave): An event fired when a user stops hovering over a given rating.

Event's payload equals to the rating of the last item being hovered over.

Movie rating example


It can be used with angular forms and reactive forms, for example:


  

form is valid: {{ form.valid ? 'true' : 'false' }}

{{ formRating }}

Predefined themes

Add the rating theme either in

index.html

Or in the global style

style.scss
(recommended)
  • Pure css stars (default)
    [theme]="'default'"
@import '~ngx-bar-rating/themes/br-default-theme'
  • Bootstrap stars
    [theme]="'bootstrap'"
@import '~ngx-bar-rating/themes/br-bootstrap-theme';
  • Fontawesome stars
    [theme]="'fontawesome'"
@import '~ngx-bar-rating/themes/br-fontawesome-theme';
  • Fontawesome-o stars
    [theme]="'fontawesome-o'"
@import '~ngx-bar-rating/themes/br-fontawesome-o-theme';
  • Horizontal bars
    [theme]="'horizontal'"
@import '~ngx-bar-rating/themes/br-horizontal-theme';
  • Vertical bars
    [theme]="'vertical'"
@import '~ngx-bar-rating/themes/br-vertical-theme';
  • Custom stars
    [theme]="'stars'"
@import '~ngx-bar-rating/themes/br-stars-theme';
  • Movie rating

    [theme]="'movie'"
    css
    @import '~ngx-bar-rating/themes/br-movie-theme';
    
  • Square rating

    [theme]="'square'"
@import '~ngx-bar-rating/themes/br-square-theme';

Rating style can be easily customized, check the classes used in any theme and add your own css.

You can also do the same for forms classes such as

untouched, touched, dirty, invalid, valid ...etc

If you have a nice rating style you would like to share, prupose your theme and I will include it in the package.

Issues

If you identify any errors in this component, or have an idea for an improvement, please open an issue. I am excited to see what the community thinks of this project, and I would love your input!

Author

Murhaf Sousli

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.