Code Monkey home page Code Monkey logo

material-icons's Introduction

Latest icon fonts and CSS for self-hosting material design icons.

This package is automatically updated, so it will always have the latest icons from Google.

For Material Symbols, see material-symbols

For SVGs, see @material-design-icons/svg

Installation

Install the latest version using:

npm install material-icons@latest

Note: If you are upgrading from 0.x to 1.x see the 1.0.0 release notes.

Usage

Import in JS (example: src/index.js in Create React App, src/main.js in Vue CLI):

import 'material-icons/iconfont/material-icons.css';

or import in CSS (example: src/styles.css in Angular CLI):

@import 'material-icons/iconfont/material-icons.css';

or import in HTML:

<link href="/path/to/material-icons/iconfont/material-icons.css" rel="stylesheet">

To display an icon, use one of the following:

<span class="material-icons">pie_chart</span>          <!-- Filled -->
<span class="material-icons-outlined">pie_chart</span> <!-- Outlined -->
<span class="material-icons-round">pie_chart</span>    <!-- Round -->
<span class="material-icons-sharp">pie_chart</span>    <!-- Sharp -->
<span class="material-icons-two-tone">pie_chart</span> <!-- Two Tone -->

Reducing Build Size

The default material-icons.css includes CSS for all fonts. This may cause build tools such as webpack to copy all fonts to the build directory even if you are not using all of them. To reduce the build size, import only the styles you need. For example, if you only need filled and outlined icons, import filled.css and outlined.css instead of the default material-icons.css:

-import 'material-icons/iconfont/material-icons.css';
+import 'material-icons/iconfont/filled.css';
+import 'material-icons/iconfont/outlined.css';
Show all
Icons CSS Sass
Filled filled.css filled.scss
Outlined outlined.css outlined.scss
Round round.css round.scss
Sharp sharp.css sharp.scss
Two Tone two-tone.css two-tone.scss

Using Sass

Import in Sass (example: src/styles.scss in Angular CLI):

@import 'material-icons/iconfont/material-icons.scss';

Available Sass variables:

$material-icons-font-path: './' !default;
$material-icons-font-size: 24px !default;
$material-icons-font-display: block !default;

If you are getting errors with webpack or Vue CLI, add this line before importing:

$material-icons-font-path: '~material-icons/iconfont/';

Using Angular mat-icon

To display an icon, use one of the following:

<mat-icon>pie_chart</mat-icon>
<mat-icon fontSet="material-icons-outlined">pie_chart</mat-icon>
<mat-icon fontSet="material-icons-round">pie_chart</mat-icon>
<mat-icon fontSet="material-icons-sharp">pie_chart</mat-icon>
<mat-icon fontSet="material-icons-two-tone">pie_chart</mat-icon>

Using CSS Classes

Alternatively, you may use CSS classes instead of ligatures to display icons. Learn more

Available Icons

See demo.

License

Material design icons are created by Google.

We have made these icons available for you to incorporate into your products under the Apache License Version 2.0. Feel free to remix and re-share these icons and documentation in your products. We'd love attribution in your app's about screen, but it's not required.

material-icons's People

Contributors

brunowego avatar dependabot[bot] avatar github-actions[bot] avatar marella avatar oleksiismerdov avatar robert-w-gries avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

material-icons's Issues

A lot of icons are not displayable

Following Icons are inside of _codepoints.scss but they are not displayable:

  • 'battery_20',
  • 'battery_30',
  • 'battery_50',
  • 'battery_60',
  • 'battery_80',
  • 'battery_90',
  • 'battery_charging_20',
  • 'battery_charging_30',
  • 'battery_charging_50',
  • 'battery_charging_60',
  • 'battery_charging_80',
  • 'battery_charging_90',
  • 'copy',
  • 'cut',
  • 'paste',
  • 'signal_cellular_0_bar',
  • 'signal_cellular_1_bar',
  • 'signal_cellular_2_bar',
  • 'signal_cellular_3_bar',
  • 'signal_cellular_4_bar',
  • 'signal_cellular_connected_no_internet_1_bar',
  • 'signal_cellular_connected_no_internet_2_bar',
  • 'signal_cellular_connected_no_internet_3_bar',
  • 'signal_wifi_1_bar',
  • 'signal_wifi_1_bar_lock',
  • 'signal_wifi_2_bar',
  • 'signal_wifi_2_bar_lock',
  • 'signal_wifi_3_bar',
  • 'signal_wifi_3_bar_lock',
  • 'signal_wifi_4_bar',
  • 'signal_wifi_connected_no_internet_0',
  • 'signal_wifi_connected_no_internet_1',
  • 'signal_wifi_connected_no_internet_2',
  • 'signal_wifi_connected_no_internet_3',
  • 'signal_wifi_statusbar_1_bar',
  • 'signal_wifi_statusbar_2_bar',
  • 'signal_wifi_statusbar_3_bar',
  • 'signal_wifi_statusbar_connected_no_internet',
  • 'signal_wifi_statusbar_connected_no_internet_1',
  • 'signal_wifi_statusbar_connected_no_internet_2',
  • 'signal_wifi_statusbar_connected_no_internet_3',
  • 'signal_wifi_statusbar_not_connected',

Thanks for your work! It seems to be the only way to use material icons via npm ๐Ÿ‘

Where's the actual font file?

There is a reference to

font-family: 'Material Icons';

but the font does not seem to be included in the npm package.

CSS usage doesn't work

The usage via css is currently not working.
The icons only will be displayed if I add the following (from iconfont folder) to my own css:

@font-face {
font-family: "Material Icons";
font-style: normal;
font-weight: 400;
font-display: block;
src: url("~material-icons/iconfont/material-icons.woff2") format("woff2"), url("~material-icons/iconfont/material-icons.woff") format("woff");
}
.material-icons {
font-family: "Material Icons";
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
font-feature-settings: "liga";
}

this I have to do for each style (outlined, etc.)

is this the wanted behaviour? then it should be mentioned in the docs.

Automatically generated typescript types

Hello, would you be interested in a PR that generates an index.d.ts file with each release? The codepoints.js script would be extended to parse the the_data/codepoints.json file and generate a set of types. Something like:

export type MaterialIconSet = [
  ...
  "ac_unit",
  "access_alarm",
  "access_alarms",
  "access_time",
  "access_time_filled",
  "accessibility",
  "accessibility_new",
  "accessible",
  "accessible_forward",
  "account_balance",
  "account_balance_wallet",
  "account_box",
  "account_circle",
  "account_tree",
  ...
];

export type MaterialIcons = IconSet[number];

This feature would allow typescript apps to type check/autocomplete the icon names:

// remove 'account_box' and you can autocomplete a different icon name
const iconName: MaterialIcons = 'account_box';

Missing icon: shortcut

Hi there!

Just wanted to let you know that there is icon which I can see in the demo , but is missing in the files (I don't see it in the scss), and respectively can't be used. The icon is shortcut.

Cheers!

css-loader@6 breaks building icons

When using webpack 5 and importing via js like so:

import "material-icons";

causes the build to fail to create icons in correct format.

Help with mixins, icons not showing

I'm usign laravel 6 that work with webpack, i do this imports on app.scss:
//material-icons
$material-icons-font-path: '~material-icons/iconfont/';
@import '~material-icons/iconfont/material-icons.scss';
@import '~material-icons/iconfont/codepoints.scss';
@import '~material-icons/iconfont/mixins.scss';
@import '~material-icons/iconfont/variables.scss';
@import '~material-icons/css/material-icons.scss';
I add more imports than you recomend.
And then i use this to put an icon in a button, just for trying:
image
I run: npm run dev(and i use too: npm run watch), and reload deleting cache from browser and i get this:
image
The material icons when i use the span tag is working well, but when i use the mixins that happens. Can you help me please?

Need to get codepoint for a specific ligature

Somewhat related to #32. I now have a need to find the codepoint for a specific icon. Would it be possible to publish codepoints.json in addition to versions.json? I think my other option is to parse the font with fontkit, which seems a bit heavy handed.

How to use outlined icons

I have this line
<i class="material-icons-outlined shopping-cart">shopping_cart</i>
i also try
<i class="material-icons shopping-cart">shopping_cart_outline</i>
(dont pay attention to the shopping cart class, just for positionning)

Thanks for help !

Customize css class

Hi,

Thanks for this library ๐Ÿ‘

Only one small thing is that class="material-icons" is quite long and I would like to customize the used css class to a shorter one.

Like this:

$material-icons-css-prefix: 'mi'; // defaults to 'material-icons'
<i class="mi">pie_chart</i>
<i class="mi-outlined">pie_chart</i>
<i class="mi-round">pie_chart</i>
<i class="mi-sharp">pie_chart</i>
<i class="mi-two-tone">pie_chart</i>

Missing icons (login, logout, policy, push_pin, query_states, local_fire_department)

Monitoring icon is missing

Hi, thanks for this. I've just noticed the monitoring icon is missing. Would it be possible to add it?

image

Publish codepoints/versions.json?

I'm interested in creating an icon picker using this package, but I'd really like to have a list of icons available so I don't need to copy the list and keep it updated. Would it be possible to publish codepoints.json and/or versions.json to npm?

save_alt not displaying

I was trying to use save_alt. It doesn't appear for me.

<i aria-hidden="true" aria-label="Save" class="material-icons">save_alt</i>

Autosize

The icons are a static font size (24px), this causes problems with some frameworks like bootstrap 5 when integrating predefined sizing styles like display-1 which works with pixel points or rem and not pixels directly. There should be a setting or style sheet that overrides the size of icons to the document's default size, so each person could be free to use whatever size they want across different frameworks without resorting to manual declarations in style sheets overriding the values.

Please, remove font-size declarations from the css file or add a separated css without predefined size.

The fix for me adding new css rule in custom css file (ugly but useful):

.custom-material-icons-round {
    font-family: "Material Icons Round";
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "liga";
}

Same as original but without font size and using new class name.

Fast copy icons element?

image

I often use icon sets to look up the icons I want when developing, but it is very inconvenient, and I need to memorize the icon names every time. It would be great if you could add a click to copy directly, I think that would be very convenient.

image

Support for Material Symbols

The team at Google Fonts recently released Material Symbols, a new, much more customizable version of Material Icons.

It would be amazing if you could add support for them, by adding a second workflow looking for the latest version of Material Symbols and a separate material-symbols.css for them.

Files missing in the bundle

Hey,
first of all, thank you very much for this library, it has been very useful to me for quite a while!

This morning I tried upgrading to the latest 0.5.0 version and got hit by a build error:

NonErrorEmittedError: (Emitted value instead of an instance of Error) CssSyntaxError: C.\path\to\my\project\node_modules\material-icons\iconfont\material-icons.css:77:262:: Can't resolve 'MaterialIconsTwoTone-Regular.ttf' in 'C.\path\to\my\project\node_modules\material-icons\iconfont

It seems like the stylesheet is trying to include all kinds of versions of the newly added fonts, but not all of them are part of the bundle. The missing files are:

  • MaterialIcons-Regular.otf
  • MaterialIconsTwoTone-Regular.ttf
  • MaterialIconsSharp-Regular.ttf
  • MaterialIconsRound-Regular.ttf
  • MaterialIconsOutlined-Regular.ttf

Removing all of these results in a functioning build, but would require manually editing the source material-icons.css file. I wouldn't recommend it, I just wanted to mention it as a temporary workaround for anyone reading this.

Thank you!

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.