How to use the new Material Design Icon themes: Outlined, Rounded, Two-Tone and Sharp?

前端 未结 15 1805
清歌不尽
清歌不尽 2020-11-28 18:10

Google has revamped its Material Design Icons with 4 new preset themes:

Outlined, Rounded, Two-Tone and Sharp, in addition to the regular Fil

15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 18:27

    I was unsatisfied that until know Google hasn't yet released their new designs as font or svg icon set. Therefore I put together a small npm package to solve the problem.

    https://www.npmjs.com/package/ts-material-icons-svg

    Simply import the icons you wanna use and add them to your registry. This also supports tree shaking since only those icons are added to your project that you really want and/or need.

    npm i --save https://github.com/MarcusCalidus/ts-material-icons-svg.git
    

    to use two tone icons for example

    import {icon_edit} from 'ts-material-icons-svg/dist/twotone';
    
    matIconRegistry.addSvgIcon(
                'edit',
                domSanitizer.bypassSecurityTrustResourceUrl(icon_edit),
            );
    

    In your html template you now can use the new icon

    
    

提交回复
热议问题