Angular PrimeNG Skeleton Styling
Angular Prime NG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease.
This article will show how to use Skeleton Component Styling in Angular Prime NG. The Skeleton component serves as a stand-in for the material to be shown.
Angular PrimeNG Skeleton Styling:
- p-skeleton: It is a styling Container element
- p-skeleton-circle: It is a styling Container element of the determinate progress bar.
- p-skeleton-animation-none: It is a styling Container element of an indeterminate progress bar.
Approach: Let us create an Angular project and install the PrimeNG UI module. Then we will create a UI that will showcase Angular PrimeNG Skeleton Styling.
Creating Angular Project:
Step 1: To create an angular app, you need to install the angular command line interface through the npm command.
npm install -g angular-cli
Step 2: Now we will create an angular project.
ng new project_name
Step 3: After creating your Angular project, move into the folder to perform different operations.
cd project_name
Step 4: After creating the Angular application, Install the required module using the following command:
npm install primeng --save npm install primeicons --save
Project Structure: After running the commands mentioned in the above steps, if you open the project in an editor, you can see a similar project structure as shown below. The new component user makes or the code changes, we will be performing will be done in the source folder.
Step to Run Application: Run the application using the following command from the root directory of the project:
ng serve --open
Example 1: We are creating a UI that shows Skeleton Styling.
- app.component.html
HTML
< div style = "margin:100px" > < h2 style = "color: green" >w3wiki</ h2 > < h3 >Angular PrimeNG Skeleton Styling</ h3 > < p-skeleton width = "20rem" height = "4rem" ></ p-skeleton > </ div > |
- app.module.ts
Javascript
import { NgModule } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { SkeletonModule } from 'primeng/skeleton' ; import { AppComponent } from './app.component' ; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, SkeletonModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } |
- styles.css
CSS
.p-skeleton { margin-top : 15% ; border : 5px dotted green ; rotate: 120 deg; } |
Output: Now open your browser and go to http://localhost:4200/, you will see the following output:
Example 2: We are creating a UI that shows Skeleton Styling.
- app.component.html
HTML
< div style = "margin:100px" > < h2 style = "color: green;" > w3wiki </ h2 > < h3 >Angular PrimeNG Skeleton Styling</ h3 > < p-skeleton animation = "none" width = "20rem" height = "4rem" ></ p-skeleton > < p-skeleton width = "8rem" height = "8rem" shape = "circle" ></ p-skeleton > </ div > |
- app.module.ts
Javascript
import { NgModule } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { SkeletonModule } from 'primeng/skeleton' ; import { AppComponent } from './app.component' ; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, SkeletonModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } |
- styles.css
Javascript
.p-skeleton-none { margin-top:15%; margin-left:2%; border:5px dotted yellow; rotate: 90deg; } .p-skeleton-circle { border:5px dotted green; } |
Output: Now open your browser and go to http://localhost:4200/, you will see the following output:
Reference: https://primefaces.org/primeng/skeleton