How can I customize both the message and icon in a Dynamic Dialog component using Angular PrimeNG within a single component?

Can someone help me with styling the message and icon properties of just a single dialog in this .ts file? I'm encountering an issue where the provided .scss code is affecting the styling of all dialogs throughout the entire app, which is not what I intended. I suspect I may be misusing the ng-deep or host selectors?

.ts:

  onDelete(uuid: string): void {
    this.confirmationService.confirm({
      message: this.translateService.instant(
        'DELETE_MESSAGE',
      ),
      header: this.translateService.instant('CONFIRM'),
      icon: 'pi pi-exclamation-triangle',
      accept: () => {
        this.myServide.deleteSomething(uuid).subscribe(() => {
          this.messageService.add({
            severity: ToastSeverity.SUCCESS,
            summary: 'SUCCESS',
            detail: 'DELETED_MESSAGE',
            life: 3000,
          });
          this.getData();
        });
        this.confirmationService.close();
      },
      reject: () => {
        this.confirmationService.close();
      },
    });
  }

.scss:

:host ::ng-deep {
      .formFooter > div:nth-child(1) {
        right: 30px !important;
        height: 100px !important;
      }
    }


::ng-deep .p-dialog.p-confirm-dialog .p-confirm-dialog-message {
  color: #eb3b5a;
}

::ng-deep .pi-exclamation-triangle:before {
  color: #eb3b5a;
}

Answer №1

In order to showcase the dialog, your HTML code needs to include something similar to this:

<p-confirmPopup></p-confirmPopup>

Experiment with incorporating a custom class like so:

<p-confirmPopup styleClass="custom-class"></p-confirmPopup>

To enhance the design, apply CSS as shown below:

::ng-deep .custom-class.p-dialog.p-confirm-dialog .p-confirm-dialog-message {
  color: #eb3b5a;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the method for creating a hovering triangle on a particular element?

My navigation bar consists of two parts. On the left side, there is a logo image, and on the right side, there are 4 list elements. I am attempting to make a triangle appear at the bottom of the element when hovered. I have floated the list to the right an ...

The toggling feature seems to be malfunctioning as the div section fails to display

I'm facing an issue with my Django project while working on a template. I want to toggle the visibility of a div element between hiding and showing, but the function I used isn't working for some reason. I borrowed the function from a different t ...

What is the best way to utilize my data with Charts.js for my specific situation?

I am utilizing Charts.js in my Angular project (not AngularJS) and I am trying to create a graphic representation with data from my database that shows the distribution between men and women. However, I am struggling to figure out how to loop through the d ...

`The value of an array containing specific class elements is lost when accessed within a setTimeout

I've come across an issue while using a JavaScript file to hide several divs all sharing the same class name. The program successfully hides the divs, but when I try to make them visible again after a certain number of seconds, the array of elements b ...

Select how the Android Keyboard functions on a mobile site

Currently running into a bit of trouble with my mobile website programming. It seems to be working fine on an iPhone browser, but when my coworker views it on an Android phone, the content gets all scrunched up when the keyboard is brought up. I've b ...

The pathway specified is untraceable by the gulp system

Hey there, I've encountered an issue with my project that uses gulp. The gulpfile.js suddenly stopped working without any changes made to it. The output I'm getting is: cmd.exe /c gulp --tasks-simple The system cannot find the path specified. ...

Struggling to center the login box on the page

Recently, I've been immersed in an HTML project and took on the task of creating a login page. When I delved into the stylesheet, I inputted the following code: .login-box { width: 280px; position: absolute; top: 50% left: 50%; color: white ...

SVG Mask not functioning properly with SVGs created in Illustrator (in all web browsers)

Alright, let's get to it - I've got a couple of SVGs here. The first one is a blue circle and the second one is a map of the United States. (Both of these were created in Illustrator) Here's what I want to do: I want the map to serve as a ...

Developing a data table with JavaScript by parsing JSON data

Looking to generate a school timetable table using dummy JSON data. The JSON object structure is as follows: this._days=[ { "day": "", "config": {} }, { "day": "Monday", "config": { ...

Can a dropdown list be designed to appear as a box or div instead of the standard select option?

My idea is to use boxes to represent different options https://i.sstatic.net/rTmIj.jpg <label for="product">Choose:</label> <select name="product" id="product"> <option value="70A"> ...

Ensuring each div element has a unique bullet icon: A step-by-step guide

I am looking to dynamically create bullet icons based on the number of div elements present in a slider. For instance, if there are 2 slider divs, I want to generate 2 bullet icons within another div. If there are no div elements, then the bullets should ...

How to Ensure Uniform Visual Border-Radius Across Buttons of Varying Sizes with CSS calc() Function

I’m currently tackling a project that involves the use of two buttons with different sizes. Despite both buttons having the same specified border-radius of 6px, they seem to display differently in the browser. The smaller button appears to have a larger ...

A guide on transferring files to a PHP server using HttpClient and FormData within an Ionic framework, along with instructions on receiving files in PHP

I have an input file in mypage.html on Ionic and I want to send this file to PHP for uploading it onto the server. In mypage.page.html, I have created an input field for the file name and another input field for the file to be uploaded. <ion-header> ...

Managing development environments and webpack configuration in Angular CLI 6.0.1

Within the angular.json file, there is a section that looks like this: "configurations": { "production": { "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": ...

adjust the @page rule size for different classname matches during printing

I am attempting to adjust the @page rule size based on matching classnames, however, my research has only led me to pseudo-classes which do not seem to solve my issue. Here is a snippet of my CSS: @media print { @page { margin: 13.2mm 0mm 12.9mm; ...

Struggling to compile Angular 8 when using ng2-adsense

I have integrated the ng2-adsense Google Adsense library into my Angular applications to display ads. To set it up, I followed the guidelines provided at this link: https://github.com/scttcper/ng2-adsense/ Include the adsbygoogle.js script in the head s ...

Tips for predefining an array of React Elements in TypeScript

import { Button, ButtonGroup } from '@material-ui/core'; let buttons: React.Component[] = []; leads to an error message stating: Type 'Element' is missing the following properties from type 'Component<{}, {}, any>': con ...

The presence of a CSS-only animation can disrupt the functionality of Bootstrap4's Navbar Toggler on mobile devices

I'm currently working on a CSS-only background animation project. The goal is to have images or colors moving from left to right in an infinite loop. The code I have works as intended, but I've encountered some issues on mobile devices (specific ...

Outline of a transparent right trapezoid shape

I'm attempting to create a slanted path line that resembles this particular image. The method I am currently using involves two trapezoid shapes, positioning one on top of the other to blend in with the background, as demonstrated in this jsFiddle ex ...

Angular's power comes from its ability to handle reactive forms with the use

I would like to enhance my application by adding multiple lines using Angular Reactive - FormArray. In this scenario, there are 2 text fields. Upon entering the data and clicking the add button, I intend to append it to the existing lines. However, I am ...