The CSS Custom Properties for the IonInput component failed to apply to the helper text

I have encountered an issue with CSS Custom Properties not affecting the helper text. Despite trying to change the color of the helper text, it remained unchanged. Is there a workaround or method to define Custom Properties specifically for helper text? The code below only results in the same color as the input field, which is not what I intended. Currently using default colors.

// Code snippet for the input field
<template>
   <ion-input  label-placement="floating" color="primary"  fill="outline" placeholder="Text" label="title" helper-text="error" helper-text-color ="danger">
  </ion-input>
  <ion-button fill="clear" slot="end" aria-label="Show/hide">
          <ion-icon slot="icon-only" :icon="eyeOff" aria-hidden="true"></ion-icon>
        </ion-button>
</template>

<script lang="ts">
  import { IonInput} from '@ionic/vue';
  import { eyeOff } from 'ionicons/icons';
  import { defineComponent } from 'vue';

  export default defineComponent({
    components: {
      IonInput},
      setup() {return { eyeOff };
      },
  });
</script>

// Color code section
/* Dark Mode Colors */
:root {
    --ion-color-danger: #c5000f;
    --ion-color-danger-rgb: 197, 0, 15;
    --ion-color-danger-contrast: #ffffff;
    --ion-color-danger-contrast-rgb: 255, 255, 255;
    --ion-color-danger-shade: #ad000d;
    --ion-color-danger-tint: #cb1a27;
}

@media (prefers-color-scheme: light) {
    :root {
        --ion-color-danger: #cb1a27;
        --ion-color-danger-rgb: 203, 26, 39;
        --ion-color-danger-contrast: #ffffff;
        --ion-color-danger-contrast-rgb: 255, 255, 255;
        --ion-color-danger-shade: #b01720;
        --ion-color-danger-tint: #d2343f;
    }
}
span.ion-text-left {
    margin-right: auto;
}

This is the current code I am working on.

Answer №1

To customize the input's CSS, you can assign a class to the input element and then update the helper-text class within the input.

<template>
  <ion-input label-placement="floating" color="primary" fill="outline" placeholder="Text" label="title" helper-text="error" class="custom"></ion-input>
  <ion-button fill="clear" slot="end" aria-label="Show/hide">
    <ion-icon slot="icon-only" :icon="eyeOff" aria-hidden="true"></ion-icon>
  </ion-button>
</template>

<script lang="ts">
  import { IonInput } from '@ionic/vue';
  import { eyeOff } from 'ionicons/icons';
  import { defineComponent } from 'vue';

  export default defineComponent({
    components: {
      IonInput
    },
    setup() {
      return {
        eyeOff
      };
    },
  });
</script>

//color codes
/* Dark Mode Colors */
:root {
  --ion-color-danger: #c5000f;
  --ion-color-danger-rgb: 197, 0, 15;
  --ion-color-danger-contrast: #ffffff;
  --ion-color-danger-contrast-rgb: 255, 255, 255;
  --ion-color-danger-shade: #ad000d;
  --ion-color-danger-tint: #cb1a27;
}

@media (prefers-color-scheme: light) {
  :root {
    --ion-color-danger: #cb1a27;
    --ion-color-danger-rgb: 203, 26, 39;
    --ion-color-danger-contrast: #ffffff;
    --ion-color-danger-contrast-rgb: 255, 255, 255;
    --ion-color-danger-shade: #b01720;
    --ion-color-danger-tint: #d2343f;
  }
}
span.ion-text-left {
  margin-right: auto;
}

ion-input.custom.ios .input-bottom .helper-text,
ion-input.custom.md .input-bottom .helper-text {
  color: var(--ion-color-danger)
}

In this example, I have set the color for both ios and md modes, but you can customize it for a specific platform if needed.

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

Changing the Width of a Material Icon

I'm currently working with Angular and Angular Material, and I have a md-button that includes both an icon and text. You can view it here: http://jsfiddle.net/u7fp5wxv Here is the code snippet for reference: <md-button layout="row" style="width: ...

Accordion elements that are active will move all other content on the page

I am currently working on creating an accordion using the following code: https://codepen.io/rafaelmollad/pen/JjRZbeW. However, I have encountered a problem where when clicking on one of the accordion items, the content expands and pushes the title upward. ...

Showing subcategories when clicked using only JavaScript

The solution can be found below I have created a dropdown menu that currently shows the submenu on hover using the following CSS: .main-menu ul li:hover > ul { display: block; } However, my design requires the submenu to appear on click and stay visi ...

IE8 not displaying background-image in Zen Subtheme of Drupal 7

I've been struggling to get my website to display properly across all browsers. Everything looks great except for IE8 and below. I'm not sure if it's a problem with Drupal, Zen, IE, or CSS (although the CSS code seems correct). Here is the C ...

Modify the div's width from 100% to 1000 pixels when it is less than 1000 pixels, using Javascript

I need help with writing Javascript code that will change the width of a div element called "red" from 100% to 1000px when the browser width is less than 1000px. The code should revert the width back to 100% when the browser width is greater than 1000px. ...

The placement of controls is not aligned properly when the validation summary is displayed at the top of the web page

Encountering an unusual issue with a custom validator function in my ASP.NET page when trying to display a validation summary at the top of the webpage using CSS styles... Here is the screen shot before clicking the submit button and making changes: Upon ...

Is there a way to show several elements simultaneously by hovering over another?

Can anyone help me with setting display:block; on all the p tags and the overlay div when I hover over my img tag? Is this achievable with just CSS or do I need to incorporate some JavaScript? Open to suggestions on the best approach. Any assistance woul ...

Aligning bootstrap side by side fields poses a challenge when labels are missing

I am struggling to design a basic bootstrap layout as I am facing challenges in aligning controls that lack labels. The problem can be seen in the provided fiddle. The controls (textbox and button) in the third column are not aligned next to the Last name ...

It's a mystery unraveling the source of CSS margins and padding

Could someone please help me analyze this webpage? I am trying to make the center of the page white up to the navigation bar, at the bottom of the page, and horizontally up to the shadows on both sides. I'm not sure where this extra padding is coming ...

Pictures fail to load on Safari browser for desktop and iPhone, yet display correctly on various other smartphones and Windows browsers

Having trouble with images not displaying on Safari browsers for Mac and iPhones, but they load fine on Windows and Android. Even after updating to the latest version of Bootstrap, the issue persists. Here are the current Bootstrap content delivery networ ...

Is there a way to change the border property of an element when clicked, without causing the displacement of other elements?

I'm in the process of creating a webpage where users can choose the color and storage capacity of an item. Only one color/capacity can be selected at a time, and once chosen, it should be highlighted with a border. The issue I encountered is that whe ...

"Learn the technique of animating SVG paths with JavaScript, a step beyond traditional HTML filling

I am looking to animate SVG path elements with JavaScript instead of HTML. I have come across numerous articles discussing how to achieve this through JavaScript and jQuery by manipulating the attributes. Some helpful links I found: Fill color SVG path w ...

The CSS styling for the font size on the <body> element is not being rendered correctly

Within my CSS styles, I have defined a selector for the body tag to establish an overall font-size of 1.5em. Specifically, the initial two words in the html section are formatted with a class that sets the font-size to 1.3em. The remaining text lacks any e ...

Tips for preventing Bootstrap 4 cards from extending to the far right side of the screen

My goal is to display a variable number of Bootstrap cards on an HTML page. The number of cards should depend on user data in the database, meaning that I need to create these cards dynamically with jQuery. One issue I encountered is that Bootstrap cards a ...

Multiplication cannot be performed on operands of type 'NoneType'

Hello everyone, I am attempting to calculate the unit price and quantity from this table using the following model: class Marketers(models.Model): category =models.ForeignKey(Category, on_delete=models.CASCADE, null=True) name =models.CharField(max ...

Is there a way to format this text horizontally?

Hey there, I'm trying to align the h4 with the p text. I attempted using display: inline-block, but it didn't do the trick. Can anyone lend a hand? Thanks in advance for any help! <h4>2.1</h4><p> Please refrain from blasphemy ...

Tri-party class switch-up

I successfully implemented two radio buttons to toggle between alternative texts: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...

Troubleshooting Vue 3: Dealing with Synchronization Issues Between Keyboard Input and

I am currently working on a Vue 3 autocomplete component and I've come across a strange issue that I can't quite figure out. The component emits two events: "update:search" to update the search variable in the parent component, and "change" whic ...

Increase the size of a centered image within a table

Lately, I've felt like my mind is starting to unravel. Here's the issue at hand: I've been attempting to resize an image within a table cell so that it spans the full width of the cell. Strangely enough, this seems to be harder than anticip ...

Adjust hover effects based on true conditions

Currently working on a web app using HTML, CSS, JavaScript, and AngularJS. Progress so far includes a clickable box that triggers a javascript function to display more boxes upon click using ng-click. <div ng-click="!(clickEnabled)||myFunction(app)" cl ...