Open In App

Angular PrimeNG Tooltip Positions

Angular PrimeNG 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. In this article, we will see how to use the Tooltip Positions in Angular PrimeNG.

Angular PrimeNG Tooltip Positions Property:



Angular PrimeNG Tooltip Positions Property values:

Syntax:



<input type="text" 
       pTooltip="..." 
       tooltipPosition="...">

Creating Angular application & module installation:

ng new appname
cd appname
npm install primeng --save
npm install primeicons --save

Project Structure: It will look like the following:

Project Structure

Example 1: Below is the example that demonstrates the use of Angular PrimeNG Tooltip Positions using top and bottom positions.




<h2 style="color: green">GeeksforGeeeks</h2>
<h5>
  PrimeNG Tooltip Positions - top and bottom
</h5>
<div class="p-grid p-fluid">
    <div class="p-col-12 p-md-3">
        <input type="text" 
               pInputText pTooltip="It is a top tooltip" 
               placeholder="Focus here..." 
               tooltipEvent="hover" 
               tooltipPosition="top" /> </div>
    <div class="p-col-12 p-md-3">
        <input type="text" 
               pInputText pTooltip="It is a bottom tooltip" 
               placeholder="Focus here..." 
               tooltipPosition="bottom" 
               tooltipEvent="hover" />
    </div>
</div>




import { Component } from "@angular/core";
  
@Component({
  selector: "my-app",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
export class AppComponent {}




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } 
    from "@angular/platform-browser/animations";
  
import { AppComponent } from "./app.component";
import { TooltipModule } from "primeng/tooltip";
import { InputTextModule } from "primeng/inputtext";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    TooltipModule,
    InputTextModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

ng serve --open

Output:

 

Example 2: Below is another example that demonstrates the use of Angular PrimeNG Tooltip Positions using the right positions,




<h2 style="color: green">GeeksforGeeeks</h2>
<h5>PrimeNG Tooltip Positions - right</h5>
<div class="p-grid p-fluid">
    <div class="p-col-12 p-md-3">
        <input type="text" 
               pInputText pTooltip="It is a bottom tooltip" 
               placeholder="Focus here..." 
               tooltipPosition="right" 
               tooltipEvent="hover" /> 
    </div>
</div>




import { Component } from "@angular/core";
  
@Component({
  selector: "my-app",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.scss"],
})
export class AppComponent {}




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from 
    "@angular/platform-browser/animations";
  
import { AppComponent } from "./app.component";
import { TooltipModule } from "primeng/tooltip";
import { InputTextModule } from "primeng/inputtext";
  
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    TooltipModule,
    InputTextModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Output:

 

Reference: https://primefaces.org/primeng/tooltip


Article Tags :