Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-knob

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-knob

An Angular component for creating knob controllers to adjust values within a specified range.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

NgxKnob

NgxKnob is an Angular component that provides a knob controller allowing users to adjust values within a specified range. This component supports both mouse and touch interactions and can be easily integrated into Angular projects.

Live Demo

Features

  • Adjustable Value: Allows users to change the value between a minimum and maximum range using mouse or touch.
  • Form Integration: Can be used with Angular forms as a ControlValueAccessor.
  • Validation Support: Supports validation of input values.

Installation

To install the library, use npm:

npm install ngx-knob --save

Usage

Importing the Module

First, add the NgxKnobModule to your Angular module:

import { NgxKnobModule } from 'ngx-knob';

@NgModule({
  imports: [
    NgxKnobModule,
    // other modules
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

Using in a Template

Use the ngx-knob component in your template as follows:

<ngx-knob [min]="0" [max]="100" [(ngModel)]="value" title="HEATING"></ngx-knob>

Component Setup

In your component, define the value property:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  value = 50;
}

Inputs and Outputs

Inputs

InputTypeDefaultDescription
titlestring'HEATING'The title displayed above the knob.
minnumber0The minimum value that the knob can represent.
maxnumber100The maximum value that the knob can represent.
valuenumber0The current value of the knob.
colorRangesIColorRange[ { "color": "#985EE1" }, { "color": "#F25656" } ]The color range3

Outputs

OutputTypeDescription
changeEventEmitter<number>Emits the new value whenever the knob's value changes.

Example

Here is a complete example of how to use the ngx-knob component:

<ngx-knob [min]="0" [max]="100" [(ngModel)]="value" title="HEATING"></ngx-knob>
<p>Value: {{ value }}</p>
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  value = 50;
}

Development and Contribution

If you want to contribute to this library, you can clone the repository and make your changes:

git clone https://github.com/mr-samani/ngx-knob.git
cd ngx-knob
npm install

Running Locally

To run the project locally and see your changes:

ng serve

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Author

💻Mohammadreza samani | FrontEnd Developer

❤️Buy me a coffee 😉

Keywords

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc