Angular App Styling With Bulma Framework

Almost everyone uses Angular CLI to get started with Angular applications. On running it, you will notice it's an app with any style written or included. Styling an Angular application has various options, as shown here.
  • Bootstrap
  • Bulma
  • Foundation
  • Handwritten CSS
In this blog, we will see how to use the Bulma CSS framework - a free, open-source CSS framework based on Flexbox. It has over 32K+ stars on GitHub with millions of downloads every month.
 
It's an apt alternative for the Bootstrap framework with no dependencies on JavaScript. As it's based on Flexbox, it's truly a responsive CSS framework from the ground.
 
Create an Angular app
 
Using Angular CLI, let's create an Angular application. Run the ng serve command just to ensure that everything works well.
 
Download Bulma
 
When using Angular, Bulma can be installed using npm. From the root folder of the Angular project, run the following command in the console.
 
npm install bulma --save
 
This will install the Bulma framework in node_modules. 

Add Bulma CSS file

The above command would have downloaded it the node_modules folder. We need to let the Angular Build System know that we need to package it while running the application.
 
For this, open angular.json from the root folder and update the styles section as shown below. This will make Angular Build System pick this CSS file while running the app.

Using in the Angular Component

Refer to the Bulma documentation to use appropriate UI style elements and patterns to style the Angular application. 
  1. import { Component } from '@angular/core';  
  2. @Component({  
  3. selector: 'app-root',  
  4. template: `  
  5.   
  6. <div class="container">  
  7.     <app-header></app-header>  
  8.     <section class="hero">  
  9.         <div class="hero-body">  
  10.             <div class="container">  
  11.                 <h1 class="title">  
  12. Angular with Bulma  
  13. </h1>  
  14.                 <h2 class="subtitle">  
  15. App is styled using Bulma  
  16. </h2>  
  17.             </div>  
  18.         </div>  
  19.     </section>  
  20.     <app-footer></app-footer>  
  21. </div>  
  22. `,  
  23. styles: []  
  24. })  
  25. export class AppComponent {  
  26. title = 'my-events';  
  27. }   
A sample Angular UI can be seen below.
 
Source Code
 
Check out the MyEvents repo on my GitHub repo.