Vue material change icon color - css

How do I change icon color for <md-icon>?
In Vue template I use it like this:
<md-icon>list_alt</md-icon>
If I look in css rendered on the page I see the default color is grey defined in css as:
.md-icon.md-theme-default.md-icon-font {
color: var(--md-theme-default-icon-on-background, rgba(0,0,0,0.54));
}

Ok, the solution is pretty simple:
<md-icon style="color:red">list_alt</md-icon>

Related

Is there any way to change disable state color of mat-slide-toggle

I want to change the color of disable state in mat-slide-toggle.
This is how slide toggle looking
This is my code
<div>
<mat-slide-toggle>Slide me!</mat-slide-toggle>
</div>
How can I change gray bg color?
In the root style.scss do a global style override (Not recommended normally) as follows. After you import the material theme
Ref: https://material.angular.io/guide/customizing-component-styles
#import '~#angular/material/prebuilt-themes/indigo-pink.css';
....
....
.mat-slide-toggle-bar {
background-color: #e47171 !important;
}
Image Ref of style import

How can I customise ionic global css colors succesfully?

I am trying to change the ion-item background to a white background with opacity to make the text more legible, however when I test out changing the colors in the variables css, i am unsuccessful.
this is the outcome when I change the color = "primary" in the html
However when I customise the color with the following code, I get no change in the view.
global CSS
--ion-color-test: #1d8f9e;
HTML
<ion-item color="test" class="item item-trns text-center">
<ion-label style="color:black!important"position="floating" >Email</ion-label>
<ion-input type="text" formControlName="email"></ion-input>
</ion-item>
I get this result
What am I doing wrong?
You need to follow this guide here:
https://ionicframework.com/docs/theming/colors#adding-colors
In short:
Create your color inside "root" selector:
:root {
// other base colors above:
// you new color below:
--ion-color-favorite: #69bb7b;
--ion-color-favorite-rgb: 105,187,123;
--ion-color-favorite-contrast: #ffffff;
--ion-color-favorite-contrast-rgb: 255,255,255;
--ion-color-favorite-shade: #5ca56c;
--ion-color-favorite-tint: #78c288;
}
Then add the class inside the variables.scss and its very important to keep the naming of the class here:
.ion-color-favorite {
--ion-color-base: var(--ion-color-favorite);
--ion-color-base-rgb: var(--ion-color-favorite-rgb);
--ion-color-contrast: var(--ion-color-favorite-contrast);
--ion-color-contrast-rgb: var(--ion-color-favorite-contrast-rgb);
--ion-color-shade: var(--ion-color-favorite-shade);
--ion-color-tint: var(--ion-color-favorite-tint);
}
The class must be written in the format .ion-color-{COLOR} where
{COLOR} is the name of the color to add
Now you can do color="favorite" in your template code.
To make it all easier Ionic team did this color creation tool:
https://ionicframework.com/docs/theming/colors#new-color-creator

How to disable Vuetify button without changing colors

I'm using Vuetify's v-btn button component with a variety of colors set via the color prop. Once a user clicks the button, I set disabled to true so they can't click it again, but the button loses its color and gets greyed out.
Is there any way to disable the button without changing its color to grey?
Instead of disabled prop you could use your custom class with pointer-events: none, e.g.
.disable-events {
pointer-events: none
}
<v-btn :class="{'disable-events': customCondition}">
Then add additional styling to that class if needed.
I do it by removing v-btn--disabled and playing with vuetify's css classes.
Still grey but with colored text solution
The button will still be grey, but text will be colored, like that you have a visual effect showing that the button is disabled but still have a colored part.
I, personally, also had some custom opacity to disabled buttons.
HTML
<v-btn id="btnA" :disabled="true" color="success">Success</v-btn>
CSS
button.v-btn[disabled] {
opacity: 0.6;
}
JS
created(){
// Trick to remove class after initialising form
this.$nextTick(() => {
document.getElementById('btnA').classList.remove('v-btn--disabled')
})
}
CodePen
Same display solution
If you really want, the same display you will have to remove [color]--text and add [color] class (and sometimes add white--text class for readability).
JS
created(){
// Trick to remove class after initialising form
this.$nextTick(() => {
document.getElementById('btnA').classList.remove('v-btn--disabled')
document.getElementById('btnA').classList.remove('success--text')
document.getElementById('btnA').classList.add('success')
})
}
CodePen
As Vuetify allready use important! in .v-btn--disabled it's not possible to just override this class. But with the use of a higher level selector like id (example: #custom-disabled which selects id="custom-disabled") you can. This doesen't keep the original colors but you are at least able to override the class to your liking.
<v-btn :disabled="true" id="custom-disabled">
Button
</v-btn>
<style>
#custom-disabled.v-btn--disabled {
background-color: red !important;
}
</style>
For light and dark theme:
<style>
#custom-disabled.v-btn--disabled.theme--light {
background-color: red !important;
}
#custom-disabled.v-btn--disabled.theme--dark {
background-color: brown !important;
}
</style>
Okay so you can do it by disabling the pointer events as mentioned in other comments but if someone is using a keyboard they can still tab to the control and if you are writing automated tests the button can still be clicked.
You can manually override the style and change the disabled button colour in the css however this will potentially be a problem if you are manually setting the color through the color="" property on v-btn based off a theme (because your application supports branding for different clients for example) because Vuetify doesn't just override the color, it stops adding the color altogether.
So my solution was to simply set the button color via a style attribute and set the important flag (to override the disabled important flag) note that you will need to change the text color as well.
<v-btn
:style="{
color: `${getTxtColor()} !important`,
backgroundColor: `${getBtnColor()} !important`
}"
:disabled="status"
#click="doSomething"
>
Click Here
</v-btn>
This approach should play nice with testing, themeing, and will not allow users to tab to the button accidentally.

Change ion-refresher & ion-infinite-scroll color

It's a "simple" request but I'm not able to achieve this result...
In my app I have these two components:
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content
pullingIcon="ios-arrow-down-outline"
pullingText="Scorri per aggiornare"
refreshingSpinner="circles"
refreshingText="Aggiornamento...">>
</ion-refresher-content>
</ion-refresher>
and
<ion-infinite-scroll [enabled]="morePagesAvailable" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content
loadingSpinner="bubbles"
loadingText="Caricando più post ...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
And they works fine with a white background. Now I need to change the background color to black but now the text of the two components it's not visible anymore because it's black by default.
How can I change che color of the two components?
I tried with a CSS class but the color it's not applied.
How is it possible to customize these components?
Thank you
As docs suggest (at least for version 1 of ionic):
The ionSpinner icon to display after user lets go of the refresher.
The SVG ionSpinner is now the default, replacing rotating font icons.
Set to none to disable both the spinner and the icon.
Closes thing in SVG to color is fill property. so you may use it instead of color.
Hope this helps
HTML Code
<ion-infinite-scroll threshold="100px" (ionInfinite)="loadData($event)">
<ion-infinite-scroll-content class="loadingspinner"
loadingSpinner="crescent"
loadingText="Loading...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
Respective CSS
.loadingspinner{
--color : #adadad;
}
.spinner-crescent{
color: #adadad;
}
If this helps someone. You have to add a class to the infinite scroll content or just use the tag selector.
<ion-infinite-scroll [enabled]="morePagesAvailable" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content
class="infinite-scroll-color"
loadingSpinner="bubbles"
loadingText="Caricando più post ...">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
And then change the stroke property of the tag line, to change the spinner svg color.
.infinite-scroll-color {
line {
stroke: #YOURCOLOR;
}
//If you want to change the text color too, just add this css
.infinite-loading-text {
color: #YOURCOLOR;
}
}
Cheers!

How to edit css for jquery datepicker prev/next buttons?

Using the JQuery UI datepicker, in the header it gives you the option to go to the next month or previous month with left/right arrows. My question is what is the css property to change the colors when hovering over the previous or next arrows?
ui-state-hover is the class that is applied when hovering, see here
It's a little harder than it seems. As NimChipsky pointed out, it's in ui-state-hover, but the colors aren't there directly.
If you look at ui-state-hover, out of the box, you will see something that looks like:
background-image: url("images/ui-icons_222222_256x240.png");
Basically, this is telling you that you will be using an icon sheet with color #222222, but the icon sheet graphic has to be available. You can generate other icon sheets directly, with other colors, by using the jQuery UI theme builder.
<script>
$(".ui-datepicker-next, .ui-datepicker-prev").hover(function () {
$(this).addClass("hover");
},
function () {
$(this).removeClass("hover");
});
</script>
and css for your class 'hover'
.hover
{
background-image:url('paper.gif');
}

Resources