Different ways to update ngModel input appearance

Within my Ionic application, I utilize [(ngModel)] to bind and transfer input values within my class.

<ion-item>
        <ion-label color="primary" floating>flow [m <sup>3</sup> /h]</ion-label>
        <ion-input type="number" [(ngModel)]="flow" (change)="calculate()"></ion-input>
</ion-item>

The issue arises when unwanted styling is applied to my input, such as the green bottom border visible in this image

To address this, I attempted to override it in my scss file:

page-fan-choice {
    .ng-valid * {
        border-bottom-color: #dedede;
        box-shadow: none;
    }
}

However, this approach proved ineffective. Upon inspecting the console, I discovered that the default styling takes precedence over mine due to its position in the hierarchy tree, as depicted below:

.item-md.item-input.ng-valid.input-has-value:not(.input-has-focus) .item-inner {
    border-bottom-color: #32db64;
    box-shadow: inset 0 -1px 0 0 #32db64;
}
page-fan-choice .ng-valid * {
    border-bottom-color: #dedede;
    box-shadow: none;

Even attempting to use !important did not yield the desired result, as it inadvertently altered other default Ionic styles I intended to retain, like the blue bottom border upon clicking, leaving the bottom border a constant grey color (#dedede).


Is there a way to customize this ngModel styling without interfering with the existing default Ionic styles?

Answer №1

If you're struggling to override this particular CSS rule:

.item-md.item-input.ng-valid.input-has-value:not(.input-has-focus) .item-inner {}

Suppose the div you want to style has an additional class 'foo' to distinguish it. Simply modify the rule by including the extra class in your component. This way, it becomes more specific.

.foo.item-md.item-input.ng-valid.input-has-value:not(.input-has-focus) .item-inner {}

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

Enhance your web forms with jQuery Chosen's automatic formatting feature

Having trouble adding a feature to my multi-select input box using jQuery Chosen. The current functionality allows users to enter custom values not in the list. The new feature should automatically format numbers entered by users, for example: User input ...

Chrome and Firefox failing to render background property in CSS

I encountered an issue with my HTML code that I tested on both Chrome and Firefox. The background color of the first div is not displaying correctly in either browser. .box-orange { // without any position declaration background: orange; heigh ...

click event on ion card

Attempting to handle a click event within an ion-card using Ionic 5.0.2 version has presented some challenges. Despite my efforts, I have not been successful in handling the event with the expected function. Here is a snippet of my code: Dynamic card list ...

The adhesive navigation bar isn't adhering

I'm having issues with making my navbar inside a header sticky over the whole page. Despite trying various solutions like removing overflow, adjusting the flexbox, and setting a specific height on the parent element, I still can't get it to work. ...

Print Vue page with the same styling as the original

How can I add a print button to my application that prints the page with the original CSS styles? I am currently using window.print() function and have a separate file called print.scss with specific print styles. @media print { header {display:none; ...

Eliminate the empty gap preceding the slideshow

I have a slideshow and aside content in HTML. My goal is to eliminate the space below the slideshow so that the aside content can be positioned right next to the end of the slideshow. Unfortunately, I am unsure how to remove this space without disrupting ...

Troubles with the placement of elements in a website due to

I have set up a table using PHP to display data in two columns from an XML feed. The first column appears correctly, but the second column is being cut off. For example, you can see the issue here: http://www.example.com Below is the CSS I am using: td ...

What is the best method to align these images in the center of this div?

Struggling to center the images inside the div...any suggestions? I know it's basic, just getting back into it. Hopefully someone understands what I'm trying to achieve here? Tryin' to get those images centered in the div but can't fig ...

There appears to be a TypeError in PrimeNG which states that the function "this._activeIndex.includes" is not recognized

I am working on a component that utilizes an accordion feature. My goal is to have multiple tabs enabled with a custom activeIndex. Below is the code snippet I have implemented: <p-accordion [activeIndex]="index" [multiple]="true"> <p-accordion ...

Determining if a Website is Responsive with PHP

One way to determine if a website is responsive or not is by analyzing its HTML code. A previous inquiry on this topic can be found here: . This method only focuses on checking for the <meta name="viewport" content="width=device-width"> tag. It&apos ...

spacing between elements vertically

             I am struggling with a common issue and despite searching, I have not been able to find a solution that works for me. Here is my setup: <div id="wrapper">   <div class="content-area-top"></div>   <div clas ...

What is the process of utilizing a <li> for a hover selector in jquery?

I've encountered an issue with a list that I am trying to modify its content when hovering over them. Despite using the id as a selector for triggering the hover function, all list items change color instead of just the intended one. The challenge lie ...

How to Position Input Fields over an Image Using CSS

I am working on positioning input fields over an image to allow data entry directly onto the image itself. https://i.sstatic.net/jW4iM.png Currently, I have a series of input fields (shown above) and three images with different squares on them. My goal is ...

The IIS website functions properly when accessed through localhost, but encounters issues when accessed using an IP address

My setup includes an Angular frontend paired with a .NET framework backend. The specific focus is on the web.config file, particularly the authorization/authentication settings: <location path="Tokens"> <system.webServer> <se ...

Is there a way for me to position my chat messages on the right side in the chat room?

I have a react chat application and I'm looking to customize the appearance of my messages. Currently, all entries with an orange vertical bar belong to me and are displayed on the left side of the chat room. I would like to move them to the right sid ...

Hide a div element upon selecting an option from a dropdown menu

On iPhone 6plus and lower, I created a dropdown menu that opens when users click on "jobs" or "contact." However, after clicking on these options, the drop-down menu remains open. How can I make it hide automatically after a list item is clicked at this sp ...

No response observed upon clicking on the li element within the personalized context menu

I created a custom context menu that pops up when you click on an li element within an unordered list. I'm trying to trigger an alert when clicking on an li item inside the context menu, but it's not working as expected. To handle this dynamic c ...

What is the best way to create space between Bootstrap cards without causing flex-wrap to activate?

Looking for guidance on managing Bootstrap cards with a 2px margin between them. Encountering flex-wrap issues when applying margin classes or styles directly to the cards. Any suggestions on how to handle this behavior effectively? Should I consider ad ...

The AngularJS 2 TypeScript application has been permanently relocated

https://i.stack.imgur.com/I3RVr.png Every time I attempt to launch my application, it throws multiple errors: The first error message reads as follows: SyntaxError: class is a reserved identifier in the class thumbnail Here's the snippet of code ...

Is it possible to make a div resize to fit its container?

I have a square block measuring 100*100px. The container block it is within can be resized. I need the inner block to adjust its size dynamically so that it always fits inside the parent container without overflow and maintains its square shape. Important ...