Code Monkey home page Code Monkey logo

materialdesign-angular-material's Introduction

Note: Please use the main MaterialDesign repo to report issues. This repo is for distribution of the Angular Material files only.

Angular Material - Material Design Icons

Angular Material distribution for the Material Design Icons.

Installation

Install @mdi/angular-material and @angular/cdk from npm:

npm install @mdi/angular-material @angular/cdk

Usage

This bundle is usable with AngularJS Material/Angular Material and to facilitate usage, it's recommended to use copy-webpack-plugin.

Add the following plugin configuration in the Webpack configuration:

new CopyWebpackPlugin([
  { from: 'node_modules/@mdi/angular-material/mdi.svg',
    to: 'assets/mdi.svg'
  }
]);

Or if you're using the Angular CLI, make sure to include mdi.svg in your assets folder under the Angular workspace configuration file in the assets array, located in the build configuration for your project:

```json Angular workspace configuration file
{
   // ...
   "architect": {
     "build": {
       "options": {
         "assets": [
           { "glob": "**/*", "input": "./assets/", "output": "./assets/" },
           { "glob": "favicon.ico", "input": "./", "output": "./" },
           { "glob": "mdi.svg", "input": "./node_modules/@mdi/angular-material", "output": "./assets" }
         ]
       }
     }
   }
   // ...
}
```

Note that the input directory is dependent on the workspace root which can be found by looking at your desired project's root property. (For more information, visit the Angular documentation on project configuration options.)

Additionally, see the Angular documentation on assets configuration for more information.

Note: Documentation for Angular CLI versions 1.x.x (around Angular v5) has been dropped as Angular v5 is no longer supported.

Angular Material

The mdi.svg contains all the icons provided on the site. It can be used inline with MatIconRegistry.

  1. In your app's main module (typically app.module.ts), import MatIconModule and MatIconRegistry from @angular/material/icon:
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { MatIconRegistry, MatIconModule } from '@angular/material/icon';
import { DomSanitizer } from '@angular/platform-browser';

import { HttpClientModule } from '@angular/common/http';

// ...
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    // Required by the Angular Material icon module
    HttpClientModule,
    // ...
    MatIconModule
  ]
})
export class AppModule {
  constructor(matIconRegistry: MatIconRegistry, domSanitizer: DomSanitizer){
    matIconRegistry.addSvgIconSet(
      domSanitizer.bypassSecurityTrustResourceUrl('./assets/mdi.svg')
    );
  }
}
  1. The SVG icons can then be used with MatIcon's svgIcon attribute as shown below:
<mat-icon svgIcon="<name of icon>"></mat-icon>

For more information about SVG icons, check out the documentation.

StackBlitz demo

AngularJS Material

The mdi.svg contains all the icons provided on the site. Use inline with $mdIconProvider.

var app = angular.module('myApp', ['ngMaterial']);
app.config(function($mdIconProvider) {
  $mdIconProvider
    .defaultIconSet('assets/mdi.svg')
});

Usage

<md-icon md-svg-icon="android"></md-icon>
<md-button aria-label="Android" class="md-icon-button">
  <md-icon md-svg-icon="android"></md-icon>
</md-button>

Related Packages

NPM @MDI Organization

Learn More

materialdesign-angular-material's People

Contributors

edricchan03 avatar hitomitenshi avatar mririgoyen avatar shubham-vunet avatar superitman avatar templarian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

materialdesign-angular-material's Issues

[3.5.94] Bad path for svg icons in mdi.svg

With the last version (3.5.94), the mdi.svg file seems have a problem with the path tag :
<svg><defs><svg id="access-point-network-off"><path d="mdi-access-point-network-off"/></svg>...
instead of
<svg><defs><svg id="access-point-network-off"><path d="M14.83,13.83C15.55,13.11 16,12.11 16,11C16,9.89 15.55,8.89 14.83,8.17L16.24,6.76C17.33,7.85 18,9.35 18,11C18,12.65 17.33,14.15 16.24,15.24L14.83,13.83M14,11C14,9.9 13.1,9 12,9C11.4,9 10.87,9.27 10.5,9.68L13.32,12.5C13.73,12.13 14,11.6 14,11M17.66,16.66L19.07,18.07C20.88,16.26 22,13.76 22,11C22,8.24 20.88,5.74 19.07,3.93L17.66,5.34C19.11,6.78 20,8.79 20,11C20,13.22 19.11,15.22 17.66,16.66M22,21.18V20H20.82L22,21.18M20.27,22L21,22.73L19.73,24L17.73,22H15C15,22.55 14.55,23 14,23H10C9.45,23 9,22.55 9,22H2V20H9C9,19.45 9.45,19 10,19H11V15.27L8.34,12.61C8.54,13.07 8.82,13.5 9.17,13.83L7.76,15.24C6.67,14.15 6,12.65 6,11C6,10.77 6,10.54 6.04,10.31L4.37,8.64C4.14,9.39 4,10.18 4,11C4,13.22 4.89,15.22 6.34,16.66L4.93,18.07C3.12,16.26 2,13.76 2,11C2,9.61 2.29,8.28 2.81,7.08L1,5.27L2.28,4L3.7,5.42L5.15,6.87L6.63,8.35V8.35L8.17,9.9L10.28,12L11,12.71L18.27,20H18.28L20.28,22H20.27M15.73,20L13,17.27V19H14C14.55,19 15,19.45 15,20H15.73Z"/></svg>...
in previous versions.
This break all custom icons provided by the MDI :)

New release?

We use the NPM package, but since this is two major versions behind with the material design icons, I was wondering whether this is no longer recommended?

svg tag vs g tag?

In the Angular Material example, they are using <svg> tags within the SVG <defs> tag:

https://github.com/angular/material2/blob/7f8fd9fc06bf6e49162cc144d44fc4261e11a4e8/src/demo-app/icon/icon-demo.ts#L48-L67

EDIT: Here's the code as shown above:

const INLINE_ICON_SET = `
  <svg>
    <defs>
    <svg id="account-balance">
      <path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-` +
        `7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z"/>
    </svg>
    <svg id="account-balance-wallet">
      <path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-` +
        `2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9` +
        `-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
      />
    </svg>
    <svg id="account-box">
      <path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H` +
        `5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-` +
        `3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z"/>
    </svg>
    </defs>
  </svg>
`;

However, by default, MDI is compiled with the <g> tag:

<svg>
  <defs>
    <g id="...">
      ...
    </g>
  </defs>
</svg>

In your opinion, which feels better? <svg>, or <g>?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.