ion-input with floating label placeholder colour is not changing in ionic - ionic-framework

I want to change the placeholder colour of ion-input but i'm unable to change the placeholder colour. I have ion-input with floating label. here is my workaround...
<ion-item>
<ion-label floating>first Name</ion-label>
<ion-input type="text"></ion-input>
</ion-item>
what i have tried and not working...
1) $text-input-placeholder-color
2)
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
color: pink;
}
::-moz-placeholder { /* Firefox 19+ */
color: pink;
}
:-ms-input-placeholder { /* IE 10+ */
color: pink;
}
:-moz-placeholder { /* Firefox 18- */
color: pink;
}
3)
::placeholder {
color: blue;
font-size: 1.5em;
}
but nothing is working. can anyone help me to solve this?

That is not a placeholder. It is still a ion-label
To change the style of a floating ion-label,
Add this to your variable.scss
$label-ios-text-color: blue;
$label-md-text-color: blue;
$label-ios-text-color-focused: blue;
$label-md-text-color-focused: blue;
or edit your .scss
.label[floating],
.label[stacked],
.input-has-focus .label[floating] {
color: blue ;
}

ion-item.item-has-focus > ion-label {
color: red ;
}

Just giving out a somewhat simpler solution for the problem.
When you have multiple rules setting a property, i.e color: red;, CSS will apply that one that has more "priority". None of the selectors will have more priority than the keyword !important.
ion-label {
color: your-awesome-color-here !important;
}

Related

How do I change the color of a selected label in Ionic?

I want to change the color of the selected label. I'm using --color-selected in CSS, but it doesn't work.
Html
<ng-container *ngFor="let item of daily">
<ion-label id="daysName" class="favorites-label" (click)="dayName($event)">{{item.day}}</ion-label>
</ng-container>
TS
dayName($event) {
console.log('dayName', $event.target.innerHTML)
}
CSS
#daysName {
color: white;
--color-selected: red;
}
ion-label.favorites-label {
--color-selected: red;
}
You can use ngClass:
[ngClass]="{'favorites-label': step === 'step1'}"
Or
[class.favorites-labels] = "step === 'step1'"

How to make ion-select select-icon position right but just icon, select-text position left

I want it to have a standart design on ionic input elements. I have an ion-select element and this element inside select box text align-left but I want select-icon align right. I do on HTML element like that: https://ibb.co/99YXc8B. But I am not doing in the sccs style. I try a lot. Stackblitz link: https://stackblitz.com/edit/ionic-fdqf4z?file=pages%2Fhome%2Fhome.scss
Replace your CSS with this CSS code.it will works.
[inline-icon] {
font-size: 2em !important;
padding-right: 3px !important;
color: #808080ba !important;
}
.try{
color: red;
width:100%;
}
ion-select
{
max-width: 100%;
}

Ion Refresher Background color wont change ionic

I'm using an ionic refresher to refresh content on a page in my application. However, when I pull up the ion-refresher, background does not get fully set to the color I want.
This is a CSS class I'm applying to the ion-refresher:
ion-refresher {
background-color: #dedede;
}
ion-refresher-content {
background-color: #dedede;
}
And this it what the result looks like:
How do I remove the white gap between the ion refresher and the main content?
On Ionic 4, this CSS worked for me:
ion-refresher-content {
padding-bottom: 200px;
background-color: yellow;
.refresher-pulling {
position: fixed;
top: 50px;
}
}
The padding-bottom: 200px; fills up the space to show the yellow color, but it also introduces a new issue. The refresher arrow disappears! In order to keep the arrow in place and make it function normally, the .refresher-pulling and its corresponding styles are added. This way, now the app background color shows without any white gaps and also the spinner stays in place.
Hope this helps someone.
When you pull up, one div was been created called fixed-content
For remove the gap just add .fixed-content in your .scss
Example:
.fixed-content{
background:#dedede;
}
This is what got it working for me.
ion-refresher-content {
padding-bottom: 100px;
background-color: #dedede;
}
#devner's solution is not working correctly with iPhone X and kind (i.e. devices with safe-area-inset).
Proper solution (Ionic 4):
ion-refresher-content {
position: relative;
padding-bottom: 200px;
background-color: var(--base-background-color-body);
.refresher-pulling, .refresher-refreshing {
position: relative;
top: 30px;
}
}
Appendix: best UX on my opinion can be achieved with next HTML:
<ion-refresher slot="fixed" pullFactor="0.5" (ionRefresh)="onPullToRefresh($event)">
<ion-refresher-content
pullingIcon="refresh"
refreshingSpinner="crescent"
></ion-refresher-content>
</ion-refresher>

ionic4 making segment on ios to look like they look on android with css

i am trying to make the segments on ios look the same way as they look on android. refer https://beta.ionicframework.com/docs/api/segment
i tried to play with the css properties like
segment-button-checked {
--background-checked: transparent !important;
--color-checked: white !important;
border-bottom: 1 px solid white
}
ion-segment-button {
--color: #8CA2A5;
--border-color: transparent !important
}
selected button properties does not work this way. and overall visually does not look very nice as it looks on adroid
EDIT: Ionic 4 solution
Set the segment height to match header height
ion-segment{
height: 44px;
}
Style segment button with color for the un-active segment.
Remove border and border-radius.
ion-segment-button{
font-size: 16px;
color: var(--ion-color-medium);
border: 0px;
border-radius: 0px;
}
.segment-button-checked class is used to style active state of segment.
.segment-button-checked{
background: #FFF;
color: var(--ion-color-primary);
border-bottom: 3px solid var(--ion-color-primary);
}
Original segment button:
After styling:
This can easily done by setting mode as md
<ion-segment mode="md">
<ion-segment-button value="friends">
<ion-label>Friends</ion-label>
</ion-segment-button>
<ion-segment-button value="enemies">
<ion-label>Enemies</ion-label>
</ion-segment-button>
</ion-segment>
With ionic 4 an ion-label was added and so the best approach is to customize it like this
.segment-button {
ion-label {
color: var(--ion-color-medium);
}
}
.segment-button-checked {
ion-label {
color: var(--ion-color-light) !important;
}
}
this will work well!

Change GWT Widget CSS class prefix

I have a GWT application with two TabPanels.
The TabPanel generates css-classes that has the prefix gwt-TabPanel.
Is there any way to change this prefix for one of the tables? I want to be able to style the two TabPanels independently.
To solve this I did:
Using setStylePrimaryName(String); This will change the prefix for the CSS class names that the TabPanel and TabBar uses.
tabPanel.getTabBar().setStylePrimaryName("myTabBar");
tabPanel.setStylePrimaryName("myTabPanel");
In your CSS file your add something like this:
.myTabBar {
}
.myTabBar .gwt-TabBarFirst {
width: 5px; /* first tab distance from the left */
}
.myTabBar .gwt-TabBarRest {
}
.myTabBar .gwt-TabBarItem {
margin-left: 6px;
padding: 3px 6px 3px 6px;
cursor: pointer;
cursor: hand;
color: black;
font-weight: bold;
text-align: center;
background: #3A3A3A;
}
.myTabBar .gwt-TabBarItem-selected {
cursor: default;
/* background: black; */
}
.myTabBar .gwt-TabBarItem-disabled {
cursor: default;
color: red;
}
.myTabPanel {
}
.myTapPanel .myTabPanelBottom {
border-width: 0px;
overflow: hidden;
padding: 6px;
}
For the second TabPanel you set a different with setStylePrimaryName() on both the TabPanel and the TabBar. Then you add a new section to the CSS file with the second primary name.
You can use the methods setStyleName() and addStyleName() to set or add css styles to GWT UI objects.