![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
ngx-bar-rating
Advanced tools
Minimal, light-weight Angular ratings.
If you like this plugin, please give it a star ⭐.
Install it with npm
npm i ngx-bar-rating
Import BarRating
or BarRatingModule
in your component imports.
@Component({
standalone: true,
selector: 'bars',
template: `
<bar-rating [(rate)]="rate"/>
`,
styleUrl: './example.component.scss',
imports: [BarRating]
})
export class BarsComponent {
rate: number = 4;
}
Import the theme in your global styles (unless you want to use custom template)
@import 'ngx-bar-rating/themes/br-default-theme';
Name | Description | Default |
---|---|---|
[rate] | Current rating. Can be a decimal value like 3.14 | null |
[max] | Maximal rating that can be given using this widget | 5 |
[theme] | Theme class, see available themes | default |
[readonly] | A flag that indicates if rating can be changed | false |
[showText] | Display rating title if available, otherwise display rating value | false |
[required] | A flag that indicates if rating is disabled. works only with forms | false |
[disabled] | A flag that indicates if rating is disabled. works only with forms | false |
[titles] | Titles array. array should represent all possible values including 0 | [] |
(rateChange) | A stream that emits when the rating value is changed |
BarRatingModule
provides a couple of directives to set custom rating template of your choice.
*ratingActive
: Set template, when a bar/star is active or hovered.*ratingInactive
: Set template, when a bar/star is inactive.*ratingFraction
: Set template, when a bar/star is a fraction.Here are some example:
<bar-rating [(rate)]="rate" max="5">
<i *ratingActive class="bi bi-star-fill" style="margin: 2px; color: #edb867"></i>
<i *ratingInactive class="bi bi-star-fill" style="margin: 2px; color: #d2d2d2"></i>
</bar-rating>
<bar-rating [(rate)]="rate" max="10">
<fa-icon *ratingInactive [icon]="['far', 'star']" [fixedWidth]="true" size="lg" style="color: #d2d2d2"/>
<fa-icon *ratingActive [icon]="['fas', 'star']" [fixedWidth]="true" size="lg" style="color: #50e3c2"/>
<fa-icon *ratingFraction [icon]="['fas', 'star-half-alt']" [fixedWidth]="true" size="lg" style="color: #50e3c2"/>
</bar-rating>
<bar-rating [(rate)]="rate" max="4" theme="movie" showText
[titles]="['Bad', 'Mediocre' , 'Good', 'Awesome']"/>
It can be used with Angular forms:
<form #form="ngForm">
<bar-rating name="rating" [(ngModel)]="formRating" [max]="4" required disabled/>
</form>
<p>form is valid: {{ form.valid ? 'true' : 'false' }}</p>
<pre>{{ formRating }}</pre>
And reactive forms:
<form [formGroup]="ratingForm">
<bar-rating formControlName="rate" [max]="4" required disabled/>
</form>
<p>form is valid: {{ form.valid ? 'true' : 'false' }}</p>
<pre>{{ formRating }}</pre>
To apply a scale-fade effect when a bar is clicked, simply add the effect
directive to the <bar-rating>
component:
<bar-rating effect/>
--br-font-size
: Defines the font size for the step element. Affects the themes: [default
, square
, stars
].--br-width
: Specifies the width of the step element. Affects the themes: [stars
, square
, movie
, vertical
, horizontal
].--br-height
: Specifies the height of the step element. Affects the themes: [stars
, square
, movie
, vertical
, horizontal
].--br-gap
: Sets the gap between the individual steps.--br-active-color
: Defines the color for active steps.--br-inactive-color
: Defines the color for inactive steps.--br-effect-scale
: Specifies the scale value for the scale-fade effect (e.g., 2
).--br-effect-duration
: Sets the duration of the scale-fade animation (e.g., 0.4s
).--br-effect-ease
: Defines the easing function for the scale-fade animation (e.g., ease-out
).If you want to use a custom rating template, you don't need to import any CSS theme.
If you want to use one of the predefined themes, you will need to import it in the global style style.scss
theme="default"
@import 'ngx-bar-rating/themes/br-default-theme';
theme="horizontal"
@import 'ngx-bar-rating/themes/br-horizontal-theme';
theme="vertical"
@import 'ngx-bar-rating/themes/br-vertical-theme';
theme="stars"
@import 'ngx-bar-rating/themes/br-stars-theme';
theme="movie"
@import 'ngx-bar-rating/themes/br-movie-theme';
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 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!
Murhaf Sousli
8.0.1
BarRatinEffect
directive in BarRatingModule
.FAQs
Angular Bar Rating
The npm package ngx-bar-rating receives a total of 3,723 weekly downloads. As such, ngx-bar-rating popularity was classified as popular.
We found that ngx-bar-rating demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.