DEV Community

Cover image for Angular: Design Pop Over
Kurapati Mahesh
Kurapati Mahesh

Posted on

1 1

Angular: Design Pop Over

In almost every SPA, popover is very much used component in Angular.

Here, I am going to design simple pop over. Someone, who are going to make use of this can improve further based on your requirements.

Here is the code:

<!--component.html-->
<p (mouseover)="showPopOver = true" (mouseleave)="showPopOver = false">
  Show Pop Over!
</p>

<div *ngIf="showPopOver" class="pop-over">
  <p>It's a pop-over</p>
</div>
Enter fullscreen mode Exit fullscreen mode
//component.ts
import { Component, VERSION } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent {
  showPopOver = false;
}
Enter fullscreen mode Exit fullscreen mode
//component.scss
p {
  cursor: pointer;
}

.pop-over {
  position: absolute;
  align-items: center;
  justify-content: center;
  border: 1px solid black;
  border-radius: 10px;
  width: 16rem;
  padding: 8rem;
  z-index: 1;
  box-shadow: 5px 10px grey;
}

.pop-over::before {
  border-width: 10px;
  border-style: solid;
  border-color: transparent transparent grey transparent;
  top: -20px;
  left: 4px;
  content: '';
  position: absolute;
}
Enter fullscreen mode Exit fullscreen mode

Here you can see the same in live:

Hover over Show Pop over! and observe pop over being shown.

You can follow me here: https://twitter.com/urstrulyvishwak

Thanks.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay