Convert Figma logo to code with AI

valor-software logongx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)

5,523
1,690
5,523
575

Top Related Projects

170,434

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

95,657

Deliver web apps with confidence 🚀

Angular powered Bootstrap

10,152

The Most Complete Angular UI Component Library

Component infrastructure and Material Design components for Angular

6,431

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.

Quick Overview

ngx-bootstrap is a popular Angular library that provides native Angular components and directives for Bootstrap. It offers a set of fully customizable Bootstrap components written in pure Angular without jQuery dependencies, making it easier to integrate Bootstrap functionality into Angular applications.

Pros

  • Native Angular implementation, ensuring better performance and integration
  • Regularly updated to support the latest versions of Angular and Bootstrap
  • Extensive documentation and examples for each component
  • Large and active community, providing support and contributions

Cons

  • Some components may have limited customization options compared to vanilla Bootstrap
  • Learning curve for developers new to Angular or Bootstrap
  • Occasional bugs or inconsistencies between versions
  • May increase bundle size for smaller applications

Code Examples

  1. Using the DatePicker component:
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';

@NgModule({
  imports: [BsDatepickerModule.forRoot()]
})
export class AppModule {}
<input type="text" bsDatepicker>
  1. Implementing a Modal:
import { ModalModule } from 'ngx-bootstrap/modal';

@NgModule({
  imports: [ModalModule.forRoot()]
})
export class AppModule {}
<button (click)="openModal(template)">Open modal</button>
<ng-template #template>
  <div class="modal-header">
    <h4 class="modal-title pull-left">Modal</h4>
    <button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body">
    This is a modal.
  </div>
</ng-template>
  1. Using the Dropdown directive:
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';

@NgModule({
  imports: [BsDropdownModule.forRoot()]
})
export class AppModule {}
<div class="btn-group" dropdown>
  <button dropdownToggle type="button" class="btn btn-primary dropdown-toggle">
    Dropdown <span class="caret"></span>
  </button>
  <ul *dropdownMenu class="dropdown-menu" role="menu">
    <li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
    <li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
    <li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
  </ul>
</div>

Getting Started

  1. Install ngx-bootstrap and Bootstrap:

    npm install ngx-bootstrap bootstrap
    
  2. Add Bootstrap CSS to your angular.json:

    "styles": [
      "node_modules/bootstrap/dist/css/bootstrap.min.css",
      "src/styles.css"
    ]
    
  3. Import the modules you need in your app.module.ts:

    import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
    import { ModalModule } from 'ngx-bootstrap/modal';
    
    @NgModule({
      imports: [
        BsDatepickerModule.forRoot(),
        ModalModule.forRoot()
      ]
    })
    export class AppModule { }
    
  4. Use the components in your templates as shown in the code examples above.

Competitor Comparisons

170,434

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

Pros of Bootstrap

  • Wider adoption and larger community support
  • More comprehensive documentation and resources
  • Versatile and framework-agnostic, usable with various JavaScript frameworks

Cons of Bootstrap

  • Requires additional setup for Angular integration
  • May include unnecessary components and styles, potentially increasing bundle size
  • Less Angular-specific optimizations and features

Code Comparison

Bootstrap (CSS):

.btn-primary {
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

ngx-bootstrap (Angular component):

<button type="button" class="btn btn-primary">
  Primary
</button>

Key Differences

  • Bootstrap is a standalone CSS framework, while ngx-bootstrap is specifically designed for Angular applications
  • ngx-bootstrap provides Angular-native directives and components, making integration smoother in Angular projects
  • Bootstrap offers more design flexibility, while ngx-bootstrap focuses on Angular-specific functionality

Use Cases

  • Choose Bootstrap for general web development projects or when working with multiple frameworks
  • Opt for ngx-bootstrap when building Angular applications and requiring tighter integration with Angular's ecosystem

Community and Support

  • Bootstrap has a larger user base and more third-party resources
  • ngx-bootstrap benefits from Angular-specific support and regular updates aligned with Angular releases
95,657

Deliver web apps with confidence 🚀

Pros of Angular

  • Comprehensive framework with a full ecosystem of tools and libraries
  • Backed by Google, ensuring long-term support and regular updates
  • Powerful CLI for scaffolding, development, and build processes

Cons of Angular

  • Steeper learning curve due to its complexity and size
  • Heavier bundle size, which may impact initial load times
  • More opinionated, potentially limiting flexibility in some scenarios

Code Comparison

Angular (component definition):

@Component({
  selector: 'app-root',
  template: '<h1>{{title}}</h1>',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'My Angular App';
}

ngx-bootstrap (using a component):

<button type="button" class="btn btn-primary" 
        tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Simple demo
</button>

Summary

Angular is a full-featured framework offering a complete solution for web application development, while ngx-bootstrap is a library providing Bootstrap components for Angular applications. Angular offers more comprehensive tools and features but comes with a steeper learning curve. ngx-bootstrap is more focused and easier to integrate into existing Angular projects, particularly when Bootstrap styling is desired. The choice between them depends on project requirements and developer preferences.

Angular powered Bootstrap

Pros of ng-bootstrap

  • Native Angular implementation without jQuery dependency
  • Smaller bundle size and better performance
  • More consistent with Angular's philosophy and practices

Cons of ng-bootstrap

  • Fewer components and features compared to ngx-bootstrap
  • Less frequent updates and potentially slower bug fixes
  • Steeper learning curve for developers familiar with Bootstrap's jQuery-based approach

Code Comparison

ng-bootstrap:

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

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

ngx-bootstrap:

import { BsDropdownModule } from 'ngx-bootstrap/dropdown';

@NgModule({
  imports: [BsDropdownModule.forRoot()],
  // ...
})
export class AppModule { }

Both libraries offer similar functionality, but ng-bootstrap's implementation is more aligned with Angular's modular approach. ngx-bootstrap often requires importing individual modules for each component, while ng-bootstrap provides a single NgbModule for all components.

ng-bootstrap tends to have a more Angular-centric API, whereas ngx-bootstrap stays closer to Bootstrap's original jQuery-based API. This can make ng-bootstrap easier to use for developers already familiar with Angular practices, but potentially more challenging for those coming from a traditional Bootstrap background.

10,152

The Most Complete Angular UI Component Library

Pros of PrimeNG

  • More comprehensive component library with a wider range of UI elements
  • Better theming and customization options with built-in themes and a theme designer
  • Stronger focus on enterprise-level applications with advanced data handling components

Cons of PrimeNG

  • Steeper learning curve due to the extensive component library and API
  • Larger bundle size, which may impact initial load times for smaller applications
  • Some components may require additional configuration for optimal performance

Code Comparison

PrimeNG example (Calendar component):

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

@Component({
  selector: 'app-calendar',
  template: '<p-calendar [(ngModel)]="date"></p-calendar>'
})
export class CalendarComponent {
  date: Date;
}

ngx-bootstrap example (Datepicker component):

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

@Component({
  selector: 'app-datepicker',
  template: '<input type="text" bsDatepicker [(ngModel)]="date">'
})
export class DatepickerComponent {
  date: Date;
}

Both libraries offer Angular-based UI components, but PrimeNG provides a more extensive set of features and components suitable for complex enterprise applications. ngx-bootstrap, on the other hand, offers a lighter-weight solution with a focus on core Bootstrap components. The choice between the two depends on the specific needs of your project, considering factors such as application complexity, performance requirements, and development team familiarity.

Component infrastructure and Material Design components for Angular

Pros of Angular Components

  • Official Angular Material library with comprehensive documentation
  • Seamless integration with Angular's ecosystem and tooling
  • Consistent design language following Material Design principles

Cons of Angular Components

  • Larger bundle size due to comprehensive feature set
  • Steeper learning curve for developers new to Material Design
  • Less flexibility for custom styling compared to ngx-bootstrap

Code Comparison

ngx-bootstrap:

<button type="button" class="btn btn-primary" 
        tooltip="Tooltip on top" placement="top">
  Tooltip on top
</button>

Angular Components:

<button mat-raised-button
        matTooltip="Tooltip on top" matTooltipPosition="above">
  Tooltip on top
</button>

Key Differences

  • ngx-bootstrap provides Bootstrap-compatible components for Angular
  • Angular Components offers Material Design-based components
  • ngx-bootstrap allows easier integration with existing Bootstrap styles
  • Angular Components provides a more cohesive design system out-of-the-box
  • ngx-bootstrap has a smaller footprint for projects not requiring full Material Design

Both libraries offer robust solutions for Angular applications, with the choice depending on project requirements, design preferences, and existing styling frameworks.

6,431

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.

Pros of Clarity

  • Comprehensive design system with a wider range of UI components
  • Better accessibility features and compliance with WCAG guidelines
  • Stronger focus on enterprise-level applications and scalability

Cons of Clarity

  • Steeper learning curve due to its more complex architecture
  • Less flexibility for customization compared to ngx-bootstrap
  • Larger bundle size, which may impact initial load times

Code Comparison

ngx-bootstrap:

<button type="button" class="btn btn-primary" 
        tooltip="Tooltip on top">
  Hover me
</button>

Clarity:

<clr-tooltip>
  <clr-icon clrTooltipTrigger shape="info-circle" size="24"></clr-icon>
  <clr-tooltip-content clrPosition="top-right" clrSize="lg">
    <span>This is a tooltip</span>
  </clr-tooltip-content>
</clr-tooltip>

The code comparison shows that Clarity uses a more structured approach with custom elements, while ngx-bootstrap relies on attributes and classes for functionality. Clarity's approach may lead to cleaner HTML but requires more verbose markup.

Both libraries offer robust solutions for Angular applications, with ngx-bootstrap providing a lightweight option for basic Bootstrap integration, and Clarity offering a more comprehensive design system for enterprise-level projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ngx-bootstrap

ngx-bootstrap

The best way to quickly integrate Bootstrap 5 Bootstrap 4 Components with Angular

Note: ngx-bootstrap for Bootstrap 3 is still available but is no longer maintained or updated. development

npm latest version npm next version
npm version npm downloads
slack

Links

Table of contents

  1. Getting Started
  2. Usage & Demo
  3. Supporting
  4. Installation
  5. Compatibility
  6. Troubleshooting
  7. Contributing
  8. Credits
  9. License
  10. Valor Can Help

Getting Started

ngx-bootstrap provides Bootstrap components powered by Angular, so you don't need to include original JS components.

Check our Getting started guide if it's your first project with Angular Bootstrap.

Usage & Demo

Bootstrap components for Angular applications, dozens of demos and API documentation could be found here: https://valor-software.com/ngx-bootstrap/.

Supporting ngx-bootstrap

ngx-bootstrap is an Open Source (MIT Licensed) project, it's an independent project with ongoing development made possible thanks to the support of our awesome backers. If you also would like to show support or simply give back to Open Source community, please consider becoming a backing sponsor of ngx-bootstrap on OpenCollective.

All donated funds are managed transparently on OpenCollective and will be used solely for compensating work and expenses for contributors. Valor Software employees and contractors are not eligible for use of these funds.

What's in it for you? Proper recognition and exposure of your name/logo/website on our page. Our main sponsors will be presented under this section! Be the first!

Installation

You can see the below simple example working on StackBlitz

Angular CLI way

Use the Angular CLI ng add command for updating your Angular project.

ng add ngx-bootstrap
Manual way

Install ngx-bootstrap from npm:

npm install ngx-bootstrap --save

Add wanted package to NgModule imports:

import { TooltipModule } from 'ngx-bootstrap/tooltip';

@NgModule({
  ...
  imports: [TooltipModule.forRoot(),...]
  ...
})

Add component to your page:

<button type="button" class="btn btn-primary"
        tooltip="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
  Simple demo
</button>

You will need to add bootstrap css: This can be done with the css file directly in the index.html, or alternatively through a styles import in the angular.json file or via styles.scss import. However the latter two options require additionally installing bootstrap via npm.

  • Bootstrap 5
<!--- index.html -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
  • Bootstrap 4
<!--- index.html -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2">

Setting up the bootstrap version manually

As you may know ngx-bootstrap supports several bootstrap.css versions at the same time and has automatic tool to guess current used version of library, but if this guess fails you can specify version of bootstrap.css manually.

Sometimes, your project might contain some library that could interfere with the bootstrap framework, or you might have a customized version of bootstrap. The consequence is that the process of determining bootstrap version might be failed, which can break the UI. In that case, we can still set the bootstrap version manually in the bootstrapping component (i.e. AppComponent):

import { setTheme } from 'ngx-bootstrap/utils';

@Component({...})
export class AppComponent {
  constructor() {
    setTheme('bs5'); // or 'bs4'
    ...
  }
}

How to build lib for development

First time:

git clone https://github.com/valor-software/ngx-bootstrap.git
cd ngx-bootstrap
npm ci
npm run build
npm start

Compatibility

The only two dependencies are Angular and Bootstrap CSS. Here is the version compatibility list:

ngx-bootstrapAngularBootstrap CSS
18.x.x18.x.x5.x.x or 4.x.x
12.x.x17.x.x5.x.x or 4.x.x
11.x.x16.x.x5.x.x or 4.x.x
10.x.x15.x.x5.x.x or 4.x.x
9.0.014.x.x5.x.x or 4.x.x or 3.x.x
8.0.012.x.x - 13.x.x5.x.x or 4.x.x or 3.x.x
7.1.011.x.x - 12.x.x5.x.x or 4.x.x or 3.x.x
7.0.011.x.x - 12.x.x3.x.x or 4.x.x
6.0.09.x.x - 10.x.x3.x.x or 4.x.x
5.6.x7.x.x - 9.1.03.x.x or 4.x.x
5.0.0 - 5.6.07.x.x - 8.x.x3.x.x or 4.x.x
4.x.x6.x.x - 7.x.x3.x.x or 4.x.x
3.x.x6.x.x - 7.x.x3.x.x or 4.x.x
2.x.x2.x.x - 4.x.x3.x.x or 4.x.x
1.x.x2.x.x3.x.x or 4.x.x

Troubleshooting

So if you are in trouble, here's where you can look for help.

The best place to ask questions is on StackOverflow (under the ngx-bootstrap tag) where there is a strong community of individuals asking and answering questions.

You can also join our Slack channel and link your stackoverflow question there. But try to avoid asking generic help questions directly on Slack since they can easily get lost in the chat. You can also search among the existing GitHub issues.

If none of the above helped, please feel free to open a new issue.

Contribution

All contributions very welcome! And remember, contribution is not only PRs and code, but any help with docs or helping other developers to solve issues are very appreciated! Thanks in advance!

Please read our contribution guidelines.

Credits

Crossbrowser testing sponsored by Saucelabs Saucelabs

License

MIT

Valor Software Can Help

At Valor Software our people are not resources, our people are human beings, helping to create a better world through our efforts and knowledge. We are here to assist you with your project. We have a wonderful, ever-growing team that is ready and able. If you're looking for someone to guide you and your team please feel free to reach out to us on our site or at sales@valor-software.com, we would love to chat.

NPM DownloadsLast 30 Days