Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of <ion-card> using ionic2

I am trying to change the color of to lightgray I used the html code as below:

  <ion-card *ngFor="let details of checkOutAddr" round inset class="ion-card">
    <ion-item>
      <ion-row>
        <ion-col><ion-icon ios="ios-create" md="md-create" item-right class="color1"></ion-icon>
          <b>{{details.name}}</b>
        </ion-col>
      </ion-row>

      <ion-row>
        {{details.stage}}
      </ion-row>

      <ion-row>
        {{details.main}}
      </ion-row>

      <ion-row>
        {{details.state}}
      </ion-row>

      <ion-row>
        <ion-col>
          <ion-icon ios="ios-call" md="md-call" item-left></ion-icon>
            {{details.phone}} 
        </ion-col>
      </ion-row>

      <ion-row>
        <ion-col>
          <ion-icon ios="ios-mail" md="md-mail" item-left></ion-icon> 
            {{details.mail}}
        </ion-col>
      </ion-row>
    </ion-item>
  </ion-card

I used the scss code as below:

.ion-card {
        background-color: slategray !important;
    }

How do i get the look and feel as below img:

enter image description here

like image 806
Lavanya Parvathi Avatar asked Aug 24 '16 05:08

Lavanya Parvathi


People also ask

How do I change the color of my ion card?

Adding the following code to my app global stylings / theme: --ion-background-color:#eee; changes the color of ion-cards as well.

How do I change the background color in Ionic?

For some reason I solved it this way: First of all I added --ion-background-color:#ffffff; in the variables. scss file inside theme folder. After that the background was successful set.

How do I change text color in Ionic?

The text component is a simple component that can be used to style the text color of any element. The ion-text element should wrap the element in order to change the text color of that element.


1 Answers

In order to do it in a more Ionic2 way you need to replace the value of these sass variables:

$card-ios-background-color
$card-md-background-color
$card-wp-background-color

So, you just need to add the new value in app/theme/app.variables.scss, like this:

$card-ios-background-color: slategray;
$card-md-background-color: slategray;
$card-wp-background-color: slategray;
like image 99
sebaferreras Avatar answered Nov 09 '22 07:11

sebaferreras