ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - OuterlimitsTech/olt-ngx-ui-switch: Angular UI Switch (Forked)
Angular UI Switch (Forked). Contribute to OuterlimitsTech/olt-ngx-ui-switch development by creating an account on GitHub.
Visit Site

GitHub - OuterlimitsTech/olt-ngx-ui-switch: Angular UI Switch (Forked)

GitHub - OuterlimitsTech/olt-ngx-ui-switch: Angular UI Switch (Forked)

This library was copied from https://github.com/webcat12345/ngx-ui-switch

We use this library, and it seems that it takes several months for the owners to update after a major version Angular update.

Angular UI Switch Component

Description

This is a simple iOS 7 style switch component for Angular.

Live demo

A stackblitz is also available here

alt

Inspired by switchery in Angular.

Installation

npm: npm install olt-ngx-ui-switch

yarn: yarn add olt-ngx-ui-switch

Usage

  • Import into a module (AppModule example below)
// app.module.ts
import { OltUiSwitchModule } from "olt-ngx-ui-switch";
import { AppComponent } from "./app.component";

@NgModule({
  imports: [BrowserModule, OltUiSwitchModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}
  • Add default css file to appropriate project(s) angular.json
"styles": [
  "src/styles.css",
  "./node_modules/olt-ngx-ui-switch/ui-switch.component.css"
]

Alternatively, the scss version can be imported into a scss file:

@import "~olt-ngx-ui-switch/ui-switch.component.scss";

Global config

Use when you want to change default values globally.

These settings will override anything passed in via property bindings.

import { OltUiSwitchModule } from "olt-ngx-ui-switch";
import { AppComponent } from "./app.component";

@NgModule({
  imports: [
    BrowserModule,
    OltUiSwitchModule.forRoot({
      size: "small",
      color: "rgb(0, 189, 99)",
      switchColor: "#80FFA2",
      defaultBgColor: "#00ACFF",
      defaultBoColor: "#476EFF",
      checkedLabel: "on",
      uncheckedLabel: "off",
    }),
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}
<olt-ui-switch></olt-ui-switch>

Two way binding

<olt-ui-switch [(ngModel)]="enable"></olt-ui-switch>

Params

checked

type: boolean

default: false

<olt-ui-switch checked></olt-ui-switch>
<olt-ui-switch [checked]="false"></olt-ui-switch>

disabled

type: boolean

default: false

<olt-ui-switch disabled></olt-ui-switch>
<olt-ui-switch checked [disabled]="true"></olt-ui-switch>

loading

Show a loading state for the toggle button when true. Often utilized with beforeChange.

type: boolean

default: false

<olt-ui-switch [loading]="isLoading">
  <i class="fa fa-spinner fa-pulse" *ngIf="isLoading"></i>
</olt-ui-switch>

change

type: boolean

default: noop

<olt-ui-switch (change)="onChange($event)"></olt-ui-switch>

changeEvent

type: MouseEvent

default: noop

<olt-ui-switch (changeEvent)="onChangeEvent($event)"></olt-ui-switch>
<olt-ui-switch (changeEvent)="$event.stopPropagation()"></olt-ui-switch>

valueChange

type: boolean

default: noop

<olt-ui-switch (valueChange)="onValueChange($event)"></olt-ui-switch>

beforeChange

Utilize an observable to check that the toggle event should complete

type: Observable<boolean>

default: noop

<olt-ui-switch [beforeChange]="OnBeforeChange"> </olt-ui-switch>
OnBeforeChange: Observable<boolean> = new Observable((observer) => {
  const timeout = setTimeout(() => {
    observer.next(true);
  }, 2000);
  return () => clearTimeout(timeout);
});

size

type: string

default: medium

<olt-ui-switch size="small"></olt-ui-switch>
<olt-ui-switch size="large"></olt-ui-switch>

reverse

type: boolean

default: false

<olt-ui-switch reverse></olt-ui-switch>

color

type: string

default: rgb(100, 189, 99)

<olt-ui-switch color="red"></olt-ui-switch>

switchColor

type: string

default: #fff

<olt-ui-switch switchColor="#fcfcfc"></olt-ui-switch>

defaultBgColor

Default background color

type: string

default: #fff

<olt-ui-switch defaultBgColor="red"></olt-ui-switch>

defaultBoColor

Default border color

type: string

default: #dfdfdf

<olt-ui-switch defaultBoColor="black"></olt-ui-switch>

checkedLabel

Checked label (on)

type: string

default: null

<olt-ui-switch checkedLabel="on"></olt-ui-switch>

uncheckedLabel

Unchecked label (off)

type: string

default: null

<olt-ui-switch uncheckedLabel="off"></olt-ui-switch>

checkedTextColor

checked text color of the label (on)

type: string

default: black

<olt-ui-switch checkedTextColor="#7CFC00"></olt-ui-switch>

uncheckedTextColor

Unchecked text color of the label (off)

type: string

default: black

<olt-ui-switch uncheckedTextColor="red"></olt-ui-switch>

Switch Content

<olt-ui-switch uncheckedLabel="off">
  <img src="" />
</olt-ui-switch>

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory