3

Angular material is not showing up its gestures, design on following the guide present in their website.

I have followed the angular material guide, followed the steps given in the website.

HTML

<mat-radio-group>
  <mat-radio-button value="1">Option 1</mat-radio-button>
  <mat-radio-button value="2">Option 2</mat-radio-button>
</mat-radio-group>

<mat-form-field>
  <input matInput placeholder="Favorite food" value="Sushi">
</mat-form-field>

Module.ts

import { BrowserModule } from '@angular/platform-browser';
import { MatButtonModule, 
  MatFormFieldModule, 
  MatInputModule, 
  MatRippleModule, 
  MatCheckboxModule,
  MatToolbarModule,
  MatRadioModule } from '@angular/material';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';



import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    MatRadioModule,
    BrowserAnimationsModule,
    MatInputModule
  ],
  exports: [
    BrowserModule,
    MatRadioModule,
    BrowserAnimationsModule,
    MatInputModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

CSS

@import "@angular/material/prebuilt-themes/indigo-pink.css";

main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import 'hammerjs';


if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));

Package.js

{
  "name": "angular",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.5",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "1.6.6",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}

and the out put is like this:

image

how to make its design look good, thanks in advance

6
  • Can you replicate this in stackblitz? If you can reproduce it there we might be able to find the issue Commented Jan 7, 2019 at 20:27
  • In which file did you import the css? (@import "@angular/material/prebuilt-themes/indigo-pink.css";) Commented Jan 7, 2019 at 20:42
  • @IvanS95 okay, i will try to do that, and will answer here Commented Jan 8, 2019 at 4:23
  • @veben it is in the component's css file Commented Jan 8, 2019 at 4:24
  • @veben that was the only problem, thankyou, i made it in the style.css and solved the problem Commented Jan 8, 2019 at 4:32

1 Answer 1

1

You Should Add like this in Style.css

@import "~@angular/material/prebuilt-themes/deeppurple-amber.css";

Before

enter image description here

After

enter image description here

File Structure enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

If that gives errors, drop the tilde. I.E> @import "@angular/material/prebuilt-themes/deeppurple-amber.css";

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.