Top Related Projects
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
Component infrastructure and Material Design components for Angular
The Most Complete Angular UI Component Library
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
ng-bootstrap is an Angular-powered Bootstrap component library. It provides a set of native Angular components and directives that implement Bootstrap functionality without relying on jQuery or Bootstrap's JavaScript. This project aims to offer a seamless integration of Bootstrap with 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 easy implementation
- Fully customizable components with Angular-friendly APIs
Cons
- Limited to Angular applications, not usable with other frameworks
- May have a steeper learning curve for developers new to Angular
- Some advanced Bootstrap features might not be available or require custom implementation
- Potential performance overhead for very simple use cases compared to vanilla Bootstrap
Code Examples
- Using an ng-bootstrap modal:
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({...})
export class YourComponent {
constructor(private modalService: NgbModal) {}
open(content) {
this.modalService.open(content);
}
}
- Implementing a datepicker:
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input class="form-control" placeholder="yyyy-mm-dd"
name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker">
<div class="input-group-append">
<button class="btn btn-outline-secondary calendar" (click)="d.toggle()" type="button"></button>
</div>
</div>
</div>
</form>
- Creating a dropdown:
<div ngbDropdown class="d-inline-block">
<button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>Toggle dropdown</button>
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
<button ngbDropdownItem>Action - 1</button>
<button ngbDropdownItem>Another Action</button>
<button ngbDropdownItem>Something else is here</button>
</div>
</div>
Getting Started
- Install ng-bootstrap and its peer dependencies:
npm install @ng-bootstrap/ng-bootstrap @angular/localize
- Import the NgbModule in your app.module.ts:
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [NgbModule],
// ...
})
export class AppModule { }
- Add Bootstrap CSS to your project (e.g., in angular.json):
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css"
]
- Use ng-bootstrap components in your templates:
<ngb-alert [dismissible]="false">
<strong>Warning!</strong> Better check yourself, you're not looking too good.
</ngb-alert>
Competitor Comparisons
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
- Can be used with any JavaScript framework or vanilla JS
Cons of Bootstrap
- Larger file size, potentially impacting page load times
- Less seamless integration with Angular-specific features
- Requires additional setup for Angular projects
Code Comparison
Bootstrap (CSS import):
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
ng-bootstrap (Angular module import):
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [NgbModule],
// ...
})
Key Differences
- ng-bootstrap is specifically designed for Angular, while Bootstrap is framework-agnostic
- ng-bootstrap provides native Angular components, eliminating the need for jQuery
- Bootstrap offers more design flexibility, while ng-bootstrap focuses on Angular integration
- ng-bootstrap has a smaller footprint, as it only includes Angular-specific components
Use Cases
- Choose Bootstrap for non-Angular projects or when maximum design flexibility is needed
- Opt for ng-bootstrap in Angular applications for better integration and performance
- Consider Bootstrap for rapid prototyping across various frameworks
- Use ng-bootstrap when working exclusively with Angular and prioritizing smaller bundle sizes
Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
Pros of ngx-bootstrap
- Supports both Angular and AngularJS, offering broader compatibility
- Larger community and more frequent updates
- More customizable components with extensive API options
Cons of ngx-bootstrap
- Steeper learning curve due to more complex API
- Slightly larger bundle size compared to ng-bootstrap
- Some components may require more configuration to achieve desired functionality
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 ngx-bootstrap requires importing individual modules for each component, while ng-bootstrap provides a single module for all components. This approach in ngx-bootstrap allows for more granular control over which components are included in the final bundle, potentially reducing overall size if only a few components are needed.
Component infrastructure and Material Design components for Angular
Pros of Angular Components
- Official Angular Material library with a wide range of pre-built components
- Consistent design language following Material Design principles
- Extensive documentation and community support
Cons of Angular Components
- Heavier bundle size due to comprehensive component set
- Opinionated design may not fit all project aesthetics
- Steeper learning curve for customization
Code Comparison
Angular Components:
import { MatButtonModule } from '@angular/material/button';
@NgModule({
imports: [MatButtonModule],
})
export class AppModule { }
ng-bootstrap:
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [NgbModule],
})
export class AppModule { }
Key Differences
- ng-bootstrap is based on Bootstrap, while Angular Components implements Material Design
- ng-bootstrap has a smaller footprint and is more lightweight
- Angular Components offers a broader range of UI components and utilities
- ng-bootstrap may be easier to customize for Bootstrap-familiar developers
Use Cases
- Choose Angular Components for Material Design-based projects or large-scale applications
- Opt for ng-bootstrap when working with Bootstrap or requiring a smaller bundle size
Community and Maintenance
- Angular Components has more frequent updates and a larger contributor base
- ng-bootstrap has a dedicated community but smaller scale of development
The Most Complete Angular UI Component Library
Pros of PrimeNG
- Offers a more extensive set of UI components and themes
- Provides advanced features like data visualization and complex data handling
- Includes a powerful theme designer for customization
Cons of PrimeNG
- Steeper learning curve due to its extensive feature set
- Larger bundle size, which may impact initial load times
- Some components may require additional configuration
Code Comparison
ng-bootstrap:
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [NgbModule],
// ...
})
export class AppModule { }
PrimeNG:
import { ButtonModule } from 'primeng/button';
import { TableModule } from 'primeng/table';
@NgModule({
imports: [ButtonModule, TableModule],
// ...
})
export class AppModule { }
Summary
ng-bootstrap is a lightweight Angular implementation of Bootstrap components, offering a familiar Bootstrap-like experience. It's easy to integrate and use, making it suitable for projects that require basic Bootstrap functionality.
PrimeNG, on the other hand, is a more comprehensive UI component library for Angular. It provides a wider range of components and advanced features, making it suitable for complex applications. However, this comes at the cost of a steeper learning curve and potentially larger bundle sizes.
The choice between the two depends on project requirements, desired customization level, and the complexity of the UI components needed.
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 wide range of UI components
- Extensive documentation and design guidelines
- Supports both Angular and Web Components
Cons of Clarity
- Larger bundle size due to its comprehensive nature
- Steeper learning curve for developers new to the framework
- Less frequent updates compared to ng-bootstrap
Code Comparison
ng-bootstrap:
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [NgbModule],
// ...
})
export class AppModule { }
Clarity:
import { ClarityModule } from '@clr/angular';
@NgModule({
imports: [ClarityModule],
// ...
})
export class AppModule { }
Both frameworks offer easy integration with Angular applications, but Clarity provides a more comprehensive set of UI components and design guidelines. ng-bootstrap focuses specifically on Bootstrap components for Angular, while Clarity offers a complete design system with its own unique look and feel.
ng-bootstrap may be a better choice for projects that require a lightweight solution or want to maintain a Bootstrap-like appearance. Clarity is more suitable for larger applications that need a consistent design system and a wide range of pre-built components.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
NG Bootstrap - Angular-powered Bootstrap widgets
Angular widgets built from the ground up using only Bootstrap 5 CSS with APIs designed for the Angular ecosystem.
Please check our demo site and the list of issues to see all the things we are working on. Feel free to make comments there.
Table of Contents
- Demo
- Dependencies
- Installation
- Supported browsers
- Getting help
- Do you think you've found a bug?
- Contributing to the project
- Code of conduct
Demo
Please check all components we have in action at https://ng-bootstrap.github.io
Dependencies
The only dependencies are Angular, Bootstrap 5 CSS, and Popper.
Angular and Popper are explicitly listed as peer dependencies, while Bootstrap is not, as they don't release their CSS separately. The table below simply lists the exact version of Bootstrap CSS against which the corresponding versions of ng-bootstrap are tested.
ng-bootstrap | Angular | Bootstrap CSS | Popper |
---|---|---|---|
1.x.x | ^5.0.2 | 4.0.0 | |
2.x.x | ^6.0.0 | 4.0.0 | |
3.x.x | ^6.1.0 | 4.0.0 | |
4.x.x | ^7.0.0 | 4.0.0 | |
5.x.x | ^8.0.0 | 4.3.1 | |
6.x.x | ^9.0.0 | 4.4.1 | |
7.x.x, 8.x.x | ^10.0.0 | 4.5.0 | |
9.x.x | ^11.0.0 | 4.5.0 | |
10.x.x | ^12.0.0 | 4.5.0 | |
11.x.x | ^13.0.0 | 4.6.0 | |
12.x.x | ^13.0.0 | 5.0.0 | ^2.10.2 |
13.x.x | ^14.1.0 | 5.2.0 | ^2.10.2 |
14.x.x | ^15.0.0 | 5.2.3 | ^2.11.6 |
15.x.x | ^16.0.0 | 5.2.3 | ^2.11.6 |
16.x.x | ^17.0.0 | 5.3.2 | ^2.11.8 |
17.x.x | ^18.0.0 | 5.3.2 | ^2.11.8 |
18.x.x | ^19.0.0 | 5.3.3 | ^2.11.8 |
Installation
We strongly recommend using Angular CLI for setting up a new project. If you have an Angular CLI project, you could simply use our schematics to add ng-bootstrap library to it.
Just run the following:
ng add @ng-bootstrap/ng-bootstrap
It will install ng-bootstrap for the default application specified in your angular.json
.
If you have multiple projects and you want to target a specific application, you could specify the --project
option:
ng add @ng-bootstrap/ng-bootstrap --project myProject
If you prefer not to use schematics and install everything manually, please refer to the manual installation instructions on our website.
Supported browsers
We support the same browsers and versions supported by both Bootstrap 4 and Angular, whichever is more restrictive. See Angular browser support and Bootstrap browser support for more details.
Our code is automatically tested on all supported browsers.
Getting help
Please, do not open issues for the general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on StackOverflow where maintainers are looking at questions tagged with ng-bootstrap
.
StackOverflow is a much better place to ask questions since:
- there are hundreds of people willing to help on StackOverflow
- questions and answers stay available for public viewing so your question/answer might help someone else
- Stack Overflow's voting system assures that the best answers are prominently visible.
To save your and our time we will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow.
Do you think you've found a bug?
We want to fix it ASAP! But before fixing a bug we need to reproduce and confirm it.
We ask you to respect two things:
- fill the GitHub issue template by providing the bug description and appropriate versions of Angular, ng-bootstrap and TypeScript
- provide a use-case that fails with a minimal reproduction scenario using StackBlitz (you can start by forking one from our demo page)
A minimal reproduction scenario allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem.
Please note that we will be insisting on a minimal reproduction scenario in order to save maintainers time and ultimately be able to fix more bugs. We'll mark the issue as non-actionable without it and close if not heard from the reporter.
Interestingly, from our experience users often find coding problems themselves while preparing a minimal StackBlitz. We understand that sometimes it might be hard to extract essential bits of code from a larger code-base but we really need to isolate the problem before we can fix it.
Contributing to the project
Please check DEVELOPER.md for documentation on running the project locally and CONTRIBUTING.md for contribution guidelines.
Code of conduct
Please take a moment and read our Code of Conduct
Top Related Projects
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
Component infrastructure and Material Design components for Angular
The Most Complete Angular UI Component Library
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.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot