Light in home.page.html but its not working button ion-button is not looks like button, it doesn'" /> Light in home.page.html but its not working button ion-button is not looks like button, it doesn'" /> Light in home.page.html but its not working button ion-button is not looks like button, it doesn'"/>

Predefined CSS Classes not working ionic3

922 Views Asked by At

I have add

<button ion-button color="light">Light</button>

in home.page.html but its not working

button ion-button is not looks like button, it doesn't look like as button or as per the documentation here is the code of home.page.html

<ion-header>
  <ion-toolbar>
    <ion-buttons slot="start">
      <ion-menu-button></ion-menu-button>
    </ion-buttons>
    <ion-title>
      Home
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
    <ion-card class="welcome-card">
      <ion-img src="/assets/shapes.svg"></ion-img>
      <ion-card-header>
        <ion-card-subtitle>Get Started</ion-card-subtitle>
        <ion-card-title>Hello to Ionic</ion-card-title>
        <button ion-button color="primary">Light</button>
        <button ion-button>Default</button>
        <button ion-button color="secondary">Secondary</button>
        <button ion-button color="danger">Danger</button>
        <button ion-button color="dark">Dark</button>
      </ion-card-header>
      <ion-card-content>
        <p class = "balanced">Now that your app has been created, you'll want to start building out features and components. Check out some of the resources below for next steps.</p>
      </ion-card-content>
    </ion-card>
    <ion-list lines="none">
      <ion-list-header>
        <ion-label>Resources</ion-label>
      </ion-list-header>
      <ion-item href="https://beta.ionicframework.com/docs/">
        <ion-icon slot="start" color="medium" name="book"></ion-icon>
        <ion-label>Ionic Documentation</ion-label>
      </ion-item>
      <ion-item href="https://beta.ionicframework.com/docs/building/scaffolding">
        <ion-icon slot="start" color="medium" name="build"></ion-icon>
        <ion-label>Scaffold Out Your App</ion-label>
      </ion-item>
      <ion-item href="https://beta.ionicframework.com/docs/layout/structure">
        <ion-icon slot="start" color="medium" name="grid"></ion-icon>
        <ion-label>Change Your App Layout</ion-label>
      </ion-item>
      <ion-item href="https://beta.ionicframework.com/docs/theming/basics">
        <ion-icon slot="start" color="medium" name="color-fill"></ion-icon>
        <ion-label>Theme Your App</ion-label>
      </ion-item>
    </ion-list>
</ion-content>

and the result is

enter image description here

and here is the code of ---------------------------------------------------------------------- home.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';

import { HomePage } from './home.page';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild([
      {
        path: '',
        component: HomePage
      }
    ])
  ],
  declarations: [HomePage]
})
export class HomePageModule {}
1

There are 1 best solutions below

5
Abdul Basit On

Have a look into theme/variables.scss. If you have colors there just like below you can use it.

$colors: (
  primary:    #ED1B24,
  secondary:  #32db64,
  danger:     #f53d3d,
  light:      #f4f4f4,
  dark:       #222,
  orange:     #ffa500
);

Import this file in app.scss

@import './theme/variables.scss';

And use like this <button ion-button color="primary">Submit</button>