npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-toggle-button

v1.5.3

Published

Angular toggle button switch

Downloads

13,183

Readme

AngularToggleButton

This is a toggle switch button component, you can see the demo here and test it in StackBlitz.

Versions

| Angular | ng-toggle-button| | -------- |:------:| | >=15.0.0 | v1.5.x | | >=14.0.0 | v1.4.x | | >=13.0.0 | v1.3.x | | >=12.0.0 | v1.2.x | | >=11.0.0 | v1.1.x | | >=10.0.0 | v1.0.x | | >=9.0.0 | v0.2.x | | v8.x.x | v0.1.x |

Instalation

npm i ng-toggle-button

or

yarn add ng-toggle-button

Usage

Import the module

import { NgToggleModule } from 'ng-toggle-button';
@NgModule({
  ...
  imports: [
    ...,
    NgToggleModule.forRoot() //or NgToggleModule
  ],
})

Also, you can pass a global configuration for all ng-toggle component in your app

import { NgToggleModule } from 'ng-toggle-button';
@NgModule({
  ...
  imports: [
    ...,
    NgToggleModule.forRoot(config)
  ],
})

The config object is described in the table bellow

Use

<ng-toggle
  [value]="true"
  [color]="{
    unchecked: '#939da2',
    checked: '#f62d51'
  }"
></ng-toggle>

Properties

| Name | Type | Default | Description | |-------------|--------------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | value | boolean | false | Initial state of the toggle button | | speed | number | 300 | Transition time for the animation | | disabled | boolean | false | Button does not react on mouse events | | color | string | #0099CC | If String - color of the button when checked If Object - colors for the button when checked/unchecked or disabledExample: {checked: '#00FF00', unchecked: '#FF0000', disabled: '#CCCCCC'} | | labels | boolean Object | false | If boolean - shows/hides default labels If Object - sets custom labels for both states. Example: {checked: 'Foo', unchecked: 'Bar'} | | switchColor | string Object | #fff | If string - color or background property of the switch when checked If Object - colors or background property for the switch when checked/uncheked Example: {checked: '#25EF02', unchecked: 'silver'} | | width | number | 50 | Width of the button | | height | number | 22 | Height of the button | | margin | number | 3 | Space between the switch and background border | | name | string | undefined | Name to attach to the generated input field | | fontSize | number | 10 | Font size in pixels | | fontColor | string Object | undefined | If string - color when checked If Object - colors for labels when checked/uncheked Example: {checked: '#25EF02', unchecked: '#35DB15'} by default the text color is white.| | textAlign | string \| toggleConfig | {checked: 'left', unchecked: 'right'} | If string: text-align is applied both checked and unchecked labelsIf toggleConfig: Text align of checked/unchecked labelsExample: {checked: 'center', unchecked: 'center'}| | values | {checked: any, unchecked: any} | {checked: true, unchecked: false} | Values for checked and unchecked states, by default checked value is true and unchecked value is false Example: {checked: 1, unchecked: 0}.|

toggleConfig type is described below:

toggleConfig = {
  checked: string;
  unchecked: string;
  disabled?: string;
};

Outputs events

| Name | Payload | Description | | --- | ------ | ------- | | change | value | Triggered when state of the component changes. Contains: value - state of the button |

Keyboard Accessibility (WCAG)

The toggle is tabbable, and can be triggered using the spacebar - WCAG 2.4.3(A)

Development server

Clone this repo and download the dependencies. Run ng serve for a dev server. Navigate to http://localhost:4200/.