I am attempting to style a mat-checkbox (material2) according to the following requirements:
A black, always visible border (regardless of checked status) (#0000000)
When checked, the "tick" will be white(#ffffff), on a coloured(teal) background (border still visible)
When unchecked, the background(inside the border) of the checkbox should be off-white (#dddddd).
So far, I have been able to set the border color, but when checked, it disappears, behind the teal color
I can set the unchecked background color, but again, the black border disappears when I do this. If I remove this setting, the border appears, but the background color is wrong.
The scss properties I am setting are as follows:
::ng-deep .mat-checkbox .mat-checkbox-frame {
border-color: mat-color($darkPrimary, darker); //black
}
::ng-deep .mat-checkbox-background {
background-color: mat-color($darkPrimary, 200); //off-white
}
It seems that whatever I set the background as, overwrites the border style. Additionally, when I change the state of the checkbox, the black border briefly appears, then disappears again. How do I fulfil these requirements?
I realised that angular check-boxes are drawn in layers, with the "tick" layer drawn last, over the top of the black border.
// Background border
.mat-checkbox .mat-checkbox-frame {
border-color: black;
background-color: #dddddd
}
.mat-checkbox-indeterminate.mat-accent .mat-checkbox-background, .mat-checkbox-checked.mat-accent .mat-checkbox-background {
margin-top: 1px;
margin-left: 1px;
width: 18px;
height: 18px;
}
By reducing the front layers' size, and shifting it a little, the border remains visible.
To style the non checked box:
.mat-checkbox-background{
background-color: transparent;
svg path{
fill: transparent;
}
.mat-checkbox-checkmark-path {
stroke:transparent;
//stroke is the checked mark only
}
}
To style the checked box:
.mat-checkbox-indeterminate.mat-accent .mat-checkbox-background, .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: #2cc3f8 !important;
svg path {
fill: #2cc3f8 !important;
}
}
Put this in your style.css file, I have kept bg color red but you can change accordingly:
.mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
background-color: #d71e2b;
}
You can use ::ng-deep like below example.
::ng-deep mat-checkbox.yourcheckbox .mat-checkbox-frame{
border: 0px;
}
i might be late but try using this =, make some changes according to you
::ng-deep .mat-checkbox-checked .mat-checkbox-background,
::ng-deep .mat-checkbox-indeterminate .mat-checkbox-background {
background-color: #437891 !important;
}
::ng-deep .mat-checkbox .mat-checkbox-frame {
border-color: #fa3131;
}
::ng-deep .mat-checkbox-checked .mat-checkbox-background {
background-color: #fa3131 !important;
}
this worked for me:
::ng-deep .mat-checkbox {
margin-right: 8px !important;
}
To style the checked box, this worked for me:
mat-checkbox.mat-checkbox.mat-checkbox-checked label > span.mat-checkbox-inner-container > span.mat-checkbox-background > svg.mat-checkbox-checkmark {
/* MY STYLES HERE */
}
I placed it at the bottom of the global styles.css and decorated the various styles with !important
To have a blue tick on a white background when checked and a white border when not checked, the following worked for me (knowing ng-deep is deprecated):
:host ::ng-deep {
.mat-checkbox .mat-checkbox-frame {
border-color: white !important;
}
.mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: white !important;
svg path {
stroke: blue !important;
}
}
}
Angular 13 with Material 13-
<mat-checkbox color="accent" [(ngModel)]="node. Checked" (change)="checkIndeterminate(node, $event)">
{{node.name}}
</mat-checkbox>
Added this to my styles.css:
.mat-checkbox.mat-accent .mat-checkbox-frame { border-color: black !important }
.mat-checkbox.mat-accent .mat-checkbox-background { background-color: rgba(0,0,0,0); }
.mat-checkbox.mat-accent .mat-checkbox-checkmark-path { stroke: black !important }
Result: white checkbox with black border when unchecked, white checkbox with black border and black checkmark when checked.
Related
is there a way to change the color of mat-checkboxes if they're checked and enabled. I've tried something similiar to this question Scss change color of mat-checkbox if disabled and used enabled instead of disabled but it isn't working.
This is my css code for the checkboxes:
:host ::ng-deep .mat-checkbox-checked.mat-accent.mat-checkbox-enabled .mat-checkbox-background {
background-color: red !important;
}
If I swap enabled with disabled it works fine, but it's not what I want. My goal is that only checkboxes which are enabled and checked are given a ceratin color of background and tick.
youll need to add these classes to have the required colors you want ,I tested them on stackblitz for angular ,first one is for ripple color ,second one for checked background color and the third class is for icons color.
::ng-deep .mat-checkbox-ripple .mat-ripple-element {
background-color: green !important;
}
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background {
background-color: red !important;
}
::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background svg path {
stroke: blue !important;
}
/* ::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background {
color: red !important;
} */
Since an enabled control does not has any class like .enabled... you could use :not() css selector to invert that:
:host ::ng-deep .mat-checkbox-checked.mat-accent:not(.mat-checkbox-disabled) .mat-checkbox-background {
background-color: green !important;
}
I am using angular and devExpress to build this component.
<dx-text-box ...
label="Link"
labelMode="floating"
>
</dx-text-box>
I want to change the default border(color & size) and when clicking or hovering the input field.
What I want:
(normal, hover and disable state)
I have this css-classes
::ng-deep .dx-texteditor-label > div {
border-color: blue !important
}
::ng-deep .dx-state-focused .dx-texteditor-label > div {
border: 2px solid red !important; /* did not work, why*/
}
::ng-deep .dx-label {
color: purple
}
When I change only the background-color It works fine, but when using the border: 2px solid red property It is broken.
What I'm getting:
Why is this so?
Hello I am trying to remove the default background of toolbar icons when hover in firefox using userChrome.css
.toolbarbutton-icon
{
border-radius: 5px !important;
box-shadow: 0px 1px 1px 1px black, 0 -0.01em 1px 0px #D0D0D0 !important;
background-color: var(--uc-regular-colour) !important;
width: 26px !important;
height: 26px !important;
padding: 5px !important;
}
This block of code changes the size and color of all toolbar buttons including extension icons
Then I used this block of code to change its color when hover over them
*:hover > .toolbarbutton-icon{
background-color: green !important;
}
Which changes color of buttons when hover but the extension buttons stays the same.
How can I change it without having to define each extension name or property
Below are some screenshots to demonstrate the issue
As you can see except extension button all buttons change color
*:hover .toolbarbutton-icon {
background-color: green !important;
}
Tried this block as well as suggested below, but it hovers on all icons by default, I want each button to change color when hovered over them also when I hover over the extension button It still has the gray color
It will be a problem when you use >.
The > notation applies only to the immediate children of that element.
Try use:
*:hover .toolbarbutton-icon {
background-color: green !important;
}
Hope this helps.
.webextension-browser-action:hover > .toolbarbutton-badge-stack .toolbarbutton-icon { background-color: var(--uc-hover-colour) !important;}
Apparently after doing some research. Finally found a way to fix it.
The block of codes only works with extensions installed on firefox
I styled my alerts in theme/variables.scss like so (black background with white text)
ion-alert {
--background: black !important;
--color: white !important;
button {
color: white !important;
font-size: 20px !important;
}
}
<ion-item>
<ion-label>Quantity</ion-label>
<ion-select formControlName="quantity" placeholder="Select One">
<ion-select-option value="1">1</ion-select-option>
<ion-select-option value="2">2</ion-select-option>
</ion-select>
</ion-item>
Now the problem is, when I add a select menu using ion-select the radio/select text (ion-select-option) is black, so it blends in with the background of the popup. I've tried about 30 different CSS classes and none of them are having any impact.
How do I change the color of the radio text?
Figured it out. The .sc-ion-alert-md class will change the text color of the radio labels. Tested in Chrome with both iOS and Android using ionic serve.
ion-alert.select-alert {
--background: black!important;
button {
color: white !important;
font-size: 20px !important;
}
.sc-ion-alert-md {
color: white;
}
}
<ion-select> under the hood uses <ion-alert> which is why your style conflicts. You can use the :not() css to exclude the <ion-select>
ion-alert:not(.select-alert) {
--background: black !important;
--color: white !important;
button {
color: white !important;
font-size: 20px !important;
}
}
I'm trying to repaint a toggle button, but after all attempts, I still can't find the right CSS style to overwrite.
Current implementation is http://webix.com/snippet/ebbe2e11
CSS:
.webix_el_toggle button{
background-color:grey !important;
border-color: gray !important;
}
.webix_el_toggle.webix_pressed button{
background-color:green !important;
border-color: green !important;
}
As you can see, .webix_el_toggle.webix_pressed doesn't work and I've finally lost among CSS classes for the toggle. Is there a way to change it?
Ok, I've found a solution. The needed CSS class for the pressed toggle is .webix_el_box.webix_pressed:
.webix_el_toggle button{
background-color:grey !important;
border-color: gray !important;
}
.webix_el_box.webix_pressed button{
background-color:green !important;
border-color: green !important;
}
Snippet