Avoid changing the button color to a lighter shade when it is clicked

Is there a way to prevent button text from changing to a lighter color after clicking?

I am facing an issue where the button I set to red turns slightly whiteish after it is clicked. How can I ensure that the button stays red at all times?

Header Toolbar with button (myPage.ts)

<ion-header>
  <ion-toolbar>
    
    <ion-buttons>
      <ion-button style="color: red;">
        <ion-label>Done</ion-label>
      </ion-button>
    </ion-buttons>
    
  </ion-toolbar>
</ion-header>

I want the buttons to remain solid red whether they are clicked on or not.

It's unclear if this issue is related to Ionic or Angular, as all links seem to change color after being clicked.

Edit

Changing the background color does not stop the fading effect, and adjusting focus/active/visited styles doesn't seem to have any impact.

https://i.sstatic.net/4pGb2.png

https://i.sstatic.net/ljD5n.png

Interestingly, when I click away from the button, it reverts back to its full color.

(Using Ionic 5 and Angular 9)

Answer №1

Instead of adding a style tag, you can simply utilize the ion-button style from the Ionic documentation.

Just navigate to the SCSS file and add the following style:

ion-button{
    --background-activated: var(--ion-color-danger);
}

Feel free to make use of this approach.

Answer №2

Modify the appearance of the button.

button{background: skyblue}

Answer №3

If you want to customize this using CSS.

There is a special pseudo-class known as visited:

a:visited {
  color: red;
}

For more information on styling hyperlinks, check out: https://www.w3schools.com/css/css_link.asp

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

Unable to compile because error TS1039 prohibits initializers in ambient contexts

Upon updating my global Angular CLI to the latest version, I encountered an error. After some research, it seems that the issue may be related to my local CLI version (1.5.0) not being utilized for some reason. I am now unable to build the project due to t ...

What is the best way to enable `child_process.execFile` to utilize an existing running application?

I am currently developing an Electron app that is designed to launch another application, such as Photoshop, using child_process.execFile. However, I have encountered an issue where if Photoshop is already running when child_process.execFile is called, a n ...

Navigating with Angular router in a Bootstrap navigation bar

My link is not displaying as a tab (I'm using Bootstrap 4 and Angular 5). Instead, it shows up as just a plain link. This seems like it should be a simple issue, but this is my first time working with bootstrap... Thank you! <div> <nav cla ...

What causes Angular2 to detect both reference changes and primitive changes even when the OnPush flag is enabled?

Take a look at this code snippet import {Component, OnInit, Input, OnChanges, DoCheck, ChangeDetectionStrategy} from 'angular2/core' @Component({ selector: 'child1', template: ` <div>reference change for entire object: { ...

Move a div to line up with a table row when clicked using jQuery

As I mentioned in a previous post, my experience with jQuery is limited and I apologize for that. The task I am attempting to accomplish seems relatively straightforward. Here's an overview of the situation: I have a table enclosed within a div. Each ...

Encountering issues with utilizing global variables in Ionic 3

Using Ionic 3, I created a class for global variables but encountered an error Uncaught (in promise): Error: No provider for Globals! Error: No provider for Globals! at injectionError (http://localhost:8100/build/vendor.js:1590:86) at noProviderError Th ...

Tips for managing a virtual URL within an img tag

I have a situation where I need to protect the src value of an img tag to ensure server security. One recommendation I received is to use a virtual URL approach: In this scheme, the img tag references a virtual URL like /uploads/myuser/mypict.jpg which isn ...

Talebook by Syncfusion

I'm completely new to Storybook and I am currently exploring the possibility of creating a Storybook application that showcases a variety of controls, including Syncfusion controls and other custom controls that I will be developing in the future. Ha ...

How can you switch the default menu in bootstrap 5 to an off-canvas menu?

I'm currently designing a landing page using Bootstrap 5, and I want to replace the default menu with an off-canvas menu that includes a close icon. <!DOCTYPE html> <html lang="en"> <head> … </body> </html> Whi ...

Troubleshooting in Angular: Router Provider causing Testing Failures

I have a Header Component that is called on the main component, as I have a *ngIf to check which route I am in and render the header differently. The code functions correctly and the header renders differently depending on where I am in the app. I am att ...

A guide to resolving the Angular 11 error of exceeding the maximum call stack size

I am currently working with 2 modules in Angular 11 CustomerModule AccountingModule I have declared certain components as widget components in these modules that are used interchangeably: CustomerModule -> CustomerBlockInfoWidget AccountingModule -&g ...

unable to interpret information

I've encountered an issue with posting data to my webpage (page3.php). Despite using $test=$_POST['radio_second']; on the page, the test variable remains empty. Any help in resolving this would be greatly appreciated. Thank you! <p> ...

Enhance Your Images: Creating Stunning Colored Overlay Effects using HTML and CSS

I'm currently working on implementing an overlay effect for images on a webpage. The idea is that when the cursor hovers over an image, it will change color slightly. However, I'm facing some issues and the desired effect is not reflecting. How c ...

Enhance your React project by incorporating Material-UI card media elements with the ability to add

I am trying to figure out how to create an opaque colored overlay on top of an image using Material-UI. While it is possible with plain HTML, CSS, and JavaScript, I am facing some challenges with Material-UI. <Card> <CardMedia> <im ...

What is the difference between using min-height in vh versus % for the body tag

I'm trying to understand a code where the min-height of the body element is set to 100vh after previously defining the height of the html element as 100%. Why is there a need for this specific sequence? body { position: relative; overflow: hidd ...

Plugin for jQuery that paginates text when it overflows

Looking for a solution here. I have a fixed width and height div that needs to contain text. If the text exceeds the size of the div, I want it to paginate with dots at the bottom of the page indicating each page, similar to slideshow functionality. Are t ...

Does CSS include a shadow child operator?

Did you know that Google Chrome has a special feature called the shadow descendant combinator /deep/? This unique combinator allows for the selection of elements within shadow nodes. body div {...} // this doesn't target descendant divs inside shadow ...

What is the optimal strategy for managing multilingual text in a React website?

As I develop a react website with multiple localizations, I am faced with the question of how to best store UI texts for different languages. Currently, I am contemplating two approaches: One option is to store text directly in the UI code, using an objec ...

CSS - the option element is not appearing when using display:block

I am facing an issue with a select tag and its options. I have used CSS to hide all the options except for the last one which is set to display block. However, the last option is not showing up. Could this be due to the large number of options present? &l ...

Angular paginator encountered an issue while attempting to parse the template

I'm updating my data list to include pagination, and everything seems fine with retrieving data and sorting. However, when I add the paginator tag to my template, Angular shows me an error: ERROR in Errors parsing template: Unexpected closing tag " ...