I use ionic 4 and trying to change background-color ion-select-option.
html.
<div *ngIf="listName.checked" class="colorselect color_{{color.slice(1,7)}}">
<ion-select (click)="prepareColorSelector()" (ionChange)="setColor(this.color,i)" [(ngModel)]="color">
<ion-select-option (ionSelect)="selectColor(optioncolor)" *ngFor="let optioncolor of colors" [value]="optioncolor" style="background-color:optioncolor">{{optioncolor}}</ion-select-option>
</ion-select>
</div>
scss.
.colorselect {
.select-text {
width: 75px;
border-radius: 5px;
}
.alert-radio-inner,
.alert-radio-icon,
.alert-radio-label {
display: none;
}
&.colorselected:before {
content: '\2713';
color: white;
z-index: 999999;
width: 100%;
height: 100%;
font-size: 33px;
left: 50%;
top: 50%;
position: relative;
transform: translate(-50%);
}
$colorsToSelect: "#d435a2" "#a834bf" "#6011cf" "#0d0e81";
@each $colorOption in $colorsToSelect {
$colorWithoutHash: str-slice($colorOption, 2, 7);
&.color_#{$colorWithoutHash} {
&, & .select-text {
color: #{$colorOption};
background-color: #{$colorOption};
}
}
}
}
The background-color can't change. this problem only with ion-select-option.someone can help me.
A color can be applied to an Ionic component in order to change the default colors using the color attribute. Notice in the buttons below that the text and background changes based on the color set. When there is no color set on the button it uses the primary color by default.
A select should be used with child <ion-select-option> elements. If the child option is not given a value attribute then its text will be used as the value. If value is set on the <ion-select> , the selected option will be chosen based on that value.
global.scss
ion-alert {
//background color
.alert-wrapper.sc-ion-alert-md {
background-color: #f8f4aa;
--background: linear-gradient(
to right,
rgba(255, 0, 0, 0),
rgba(255, 0, 0, 1)
);
box-shadow: inset 0 0 75px rgba(255, 210, 0, 0.3),
inset 0 0 20px rgba(255, 210, 0, 0.4),
inset 0 0 30px rgba(220, 120, 0, 0.8);
}
// Header Text
.alert-title.sc-ion-alert-md {
font-size: 25px;
font-weight: 600;
font-family: "AustralisProSwash-Italic";
color: var(--ion-text-color, #00000080);
}
// checkbox border color
[aria-checked="true"].sc-ion-alert-md .alert-radio-icon.sc-ion-alert-md {
border-color: #00000080;
}
// checkbox or radio button color
.alert-radio-inner.sc-ion-alert-md {
background-color: #00000080 !important;
}
// wrap the text
.alert-radio-label.sc-ion-alert-md {
white-space: pre-line !important;
font-family: "AustralisProSwash-Italic";
color: var(--ion-text-color, #000000b3);
font-weight: bold;
}
// Height of text
.alert-tappable.sc-ion-alert-md {
height: 77px !important;
}
// Checked text color
[aria-checked="true"].sc-ion-alert-md .alert-radio-label.sc-ion-alert-md {
color: var(--ion-color-step-850, #262626);
}
// Button color
.alert-button-inner.sc-ion-alert-md {
color: #00000080;
font-weight: bold;
font-size: larger;
}
}
<ion-col size="12">
<ion-item class="select_question">
<ion-label position="floating" class="ion-text-wrap">
Select Question
</ion-label>
<ion-select>
<ion-select-option>
This is Question 1
</ion-select-option>
<ion-select-option>
This is Question 2
</ion-select-option>
</ion-select>
</ion-item>
</ion-col>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With