Code Monkey home page Code Monkey logo

ngx-pretty-checkbox's Introduction


Pretty checkbox angular

NgxPrettyCheckbox

Quickly integrate pretty checkbox Components (checkbox, switch, radio button) with Angular

Github Release Licence


Pretty checkbox preview





Changes log

ngx-pretty-checkbox angular feature
17.0.0 17.x
16.0.0 16.x
15.1.0 15.x Stateless checkbox. There is no local state to update the checkbox by the user interaction. The component emit only the new state event. Use case: for a one-way data binding. For example, when the checkbox is clicked, a request should be sent to the server and the UI should be updated if the response is successful.
15.0.0 15.x Standalone component
12.0.0 12.x
11.0.0 11.x
1.2.0 >10.x ivy
1.1.0 >8.x
1.0.4 6.x 7.x

Installation

  • Step 1

Install the pretty-checkbox from npm or yarn package manager

> npm install pretty-checkbox // or
> yarn add pretty-checkbox

Alternatively, you can also use CDN link

https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-checkbox.min.css

  • Step 2

Download pretty-checkbox angular module from npm package manager

> npm install ngx-pretty-checkbox

  • Step 3

Add dist/pretty-checkbox.min.css file from node_module of pretty-checkbox in your html or import src/pretty-checkbox.scss file in your scss file

@import '~pretty-checkbox/src/pretty-checkbox.scss';

  • Step 4

Add ngx-pretty-checkbox in your AppModule or component to import all standalone components

import { NgxPrettyCheckboxModule } from 'ngx-pretty-checkbox';

@NgModule({
  imports: [
    ...,
    NgxPrettyCheckboxModule
  ],
  ...
})
export class AppModule { 
  ...
}

Or import the ngx-pretty-checkbox standalone components to you component

import {
  NgxPrettyCheckboxComponent,
  NgxPrettyCheckboxWillChangeComponent,
  NgxPrettyHoverComponent,
  NgxPrettyHoverWillChangeComponent,
  NgxPrettyIconDirective,
  NgxPrettyImageDirective,
  NgxPrettyIndeterminateComponent,
  NgxPrettyIndeterminateWillChangeComponent,
  NgxPrettyRadioComponent,
  NgxPrettyRadioGroupDirective,
  NgxPrettyRadioWillChangeComponent,
  NgxPrettySvgDirective,
  NgxPrettyToggleComponent,
  NgxPrettyToggleWillChangeComponent,
} from 'ngx-pretty-checkbox';

@Component({
  standalone: true,
  imports: [
    NgxPrettyCheckboxComponent,
    NgxPrettyCheckboxWillChangeComponent,
    NgxPrettyHoverComponent,
    NgxPrettyHoverWillChangeComponent,
    NgxPrettyIndeterminateComponent,
    NgxPrettyIndeterminateWillChangeComponent,
    NgxPrettyRadioComponent,
    NgxPrettyRadioWillChangeComponent,
    NgxPrettyToggleComponent,
    NgxPrettyToggleWillChangeComponent,
    NgxPrettyIconDirective,
    NgxPrettyImageDirective,
    NgxPrettyRadioGroupDirective,
    NgxPrettySvgDirective
  ],
  selector: 'my-component',
  ...
})
export class MyComponent {
}

  • Step 5

Basic usage

<p-checkbox>
  Default
</p-checkbox>




Stateless usage

@Component({
  standalone: true,
  imports: [NgxPrettyCheckboxComponent],
  selector: 'app-root',
  template: `
    <p-checkbox [stateless]="true" [checked]="checked" (change)="onStateChange($event)">Stateless Checkbox</p-checkbox>
  `
})
export class MyComponent {
  
  public checked = false;

  private http = inject(HttpClient);
  private cd = inject(ChangeDetectorRef);
  
  onStateChange(change: PrettyCheckBoxChange) {
    this.http.post(...).subscribe(_ => {
      this.checked = true;
      this.cd.detectChanges();
    })
  }
}

More demos and document

There are more features like Radio buttons , Toggle , States , Animations , Border less , Lock , Scale, SCSS Settings.

Please refer the documentation to know about them.



Browser support

Works in all modern browsers.

Chrome >= 26 Firefox >= 16 Safari >= 6.1 Opera >= 15 IE >= 9

License

This project is licensed under the MIT License. Copyright (c) milad faghihi.

ngx-pretty-checkbox's People

Contributors

miladfm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-pretty-checkbox's Issues

More examples on the demo page

Hello guys! I really liked this components, but I can't find anywhere how to make a two icons component like this:
image
Can you guys please update the demo page with these examples?

Thanks!

Angular 13 compatibilty

Hi, I was testing you lib on my local project before deploying on prod, and because i'm on Angular 13, I can't use you lib without forking it.
Is there a possibility that the angular compatibility may be updated ?

Regards

Controls not rendering correctly

The HTML below is how the control gets rendered. I followed the installation steps as they are detailed. I am using .NET Core 3.0 and Angular 8.


<p-checkbox _ngcontent-djm-c0="" class="pretty p-round p-default" color="success" shape="round">
<input type="checkbox" value="undefined">
<!--bindings={"ng-reflect-ng-if": "true"}-->
<div class="state p-success">
<label> 
Success
</label>
</div>
</p-checkbox>

For comparison this is how the control is rendered in your documentation:

<p-checkbox _ngcontent-c5="" class="pretty p-round p-default" color="primary" shape="round">
<input type="checkbox" value="undefined">
<!---->
<div class="state p-primary">
<label> 
::before
Primary
::after 
</label>
</div>
</p-checkbox>

How to handle a given html-nesting

Great project. Having portable and scalable large icons is very helpful for programs used on tablets by clumsy fingers.

I am using formio, and since custom components are buggy as hell, I would like to use some global (s)css to format my radio button.

Unfortunately, the format of divs/label is given, and it is not standard. I cannot change the nesting of input within label. I can add classes. Below my attempts to make it work with pretty (add another one for correct radioboxing), but the mark does not appear.

Any ideas? The optimal solution would be to find some global scss.

<div class="pretty p-default p-round">
  <div class="state">
    <label>
      <input type="radio" name="switch1">
      <span>addd</span>
    </label>
  </div>
</div>

As created by formio, it looks like this:

<div class="form-radio radio">
    <div ref="wrapper" class="form-check">
      <label for="ey6dqlp-a" class="form-check-label label-position-right">
        <input id="ey6dqlp-a" value="a" lang="en" class="form-check-input" type="radio" name="data[radio1][ey6dqlp]" ref="input">
        <span>a</span>
      </label>
    </div>

    <div ref="wrapper" class="form-check">
      <label for="ey6dqlp-b" class="form-check-label label-position-right">
        <input id="ey6dqlp-b" value="b" lang="en" class="form-check-input" type="radio" name="data[radio1][ey6dqlp]" ref="input">
        <span>b</span>
      </label>
    </div>

Upgrade to Angular 9

Is this library still maintained? Will you be upgrading to Angular 9 anytime soon?

Upgrade to Angular 11, 12?

The peer dependency is set for @angular/core": "^10.0.14", meaning npm has a fit if you're running Angular 11 (or 12).

npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^11.2.14" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.0.14" from [email protected]
npm ERR! node_modules/ngx-pretty-checkbox
npm ERR!   ngx-pretty-checkbox@"~1.2.1" from the root project

Is this project still being maintained?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.