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

前端 未结 15 1718
清歌不尽
清歌不尽 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条回答
  • 2020-11-28 18:38

    As of 27 February 2019, there are CSS fonts for the new Material Icon themes.

    However, you have to create CSS classes to use the fonts.

    The font families are as follows:

    • Material Icons Outlined - Outlined icons
    • Material Icons Two Tone - Two-tone icons
    • Material Icons Round - Rounded icons
    • Material Icons Sharp - Sharp icons

    See the code sample below for an example:

    body {
      font-family: Roboto, sans-serif;
    }
    
    .material-icons-outlined,
    .material-icons.material-icons--outlined,
    .material-icons-two-tone,
    .material-icons.material-icons--two-tone,
    .material-icons-round,
    .material-icons.material-icons--round,
    .material-icons-sharp,
    .material-icons.material-icons--sharp {
      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-feature-settings: 'liga';
      -webkit-font-smoothing: antialiased;
    }
    
    .material-icons-outlined,
    .material-icons.material-icons--outlined {
      font-family: 'Material Icons Outlined';
    }
    
    .material-icons-two-tone,
    .material-icons.material-icons--two-tone {
      font-family: 'Material Icons Two Tone';
    }
    
    .material-icons-round,
    .material-icons.material-icons--round {
      font-family: 'Material Icons Round';
    }
    
    .material-icons-sharp,
    .material-icons.material-icons--sharp {
      font-family: 'Material Icons Sharp';
    }
    <!DOCTYPE html>
    <html>
    
    <head>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">
    </head>
    
    <body>
      <section id="original">
        <h2>Baseline</h2>
        <i class="material-icons">home</i>
        <i class="material-icons">assignment</i>
      </section>
      <section id="outlined">
        <h2>Outlined</h2>
        <i class="material-icons-outlined">home</i>
        <i class="material-icons material-icons--outlined">assignment</i>
      </section>
      <section id="two-tone">
        <h2>Two tone</h2>
        <i class="material-icons-two-tone">home</i>
        <i class="material-icons material-icons--two-tone">assignment</i>
      </section>
      <section id="rounded">
        <h2>Rounded</h2>
        <i class="material-icons-round">home</i>
        <i class="material-icons material-icons--round">assignment</i>
      </section>
      <section id="sharp">
        <h2>Sharp</h2>
        <i class="material-icons-sharp">home</i>
        <i class="material-icons material-icons--sharp">assignment</i>
      </section>
    </body>
    
    </html>

    Or view it on Codepen


    EDIT: As of 10 March 2019, it appears that there are now classes for the new font icons:

    body {
      font-family: Roboto, sans-serif;
    }
    <!DOCTYPE html>
    <html>
    
    <head>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">
    </head>
    
    <body>
      <section id="original">
        <h2>Baseline</h2>
        <i class="material-icons">home</i>
        <i class="material-icons">assignment</i>
      </section>
      <section id="outlined">
        <h2>Outlined</h2>
        <i class="material-icons-outlined">home</i>
        <i class="material-icons-outlined">assignment</i>
      </section>
      <section id="two-tone">
        <h2>Two tone</h2>
        <i class="material-icons-two-tone">home</i>
        <i class="material-icons-two-tone">assignment</i>
      </section>
      <section id="rounded">
        <h2>Rounded</h2>
        <i class="material-icons-round">home</i>
        <i class="material-icons-round">assignment</i>
      </section>
      <section id="sharp">
        <h2>Sharp</h2>
        <i class="material-icons-sharp">home</i>
        <i class="material-icons-sharp">assignment</i>
      </section>
    </body>
    
    </html>

    EDIT #2: Here's a workaround to tint two-tone icons by using CSS image filters (code adapted from this comment):

    body {
      font-family: Roboto, sans-serif;
    }
    
    .material-icons-two-tone {
      filter: invert(0.5) sepia(1) saturate(10) hue-rotate(180deg);
      font-size: 48px;
    }
    
    .material-icons,
    .material-icons-outlined,
    .material-icons-round,
    .material-icons-sharp {
      color: #0099ff;
      font-size: 48px;
    }
    <!DOCTYPE html>
    <html>
    
    <head>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp">
    </head>
    
    <body>
      <section id="original">
        <h2>Baseline</h2>
        <i class="material-icons">home</i>
        <i class="material-icons">assignment</i>
      </section>
      <section id="outlined">
        <h2>Outlined</h2>
        <i class="material-icons-outlined">home</i>
        <i class="material-icons-outlined">assignment</i>
      </section>
      <section id="two-tone">
        <h2>Two tone</h2>
        <i class="material-icons-two-tone">home</i>
        <i class="material-icons-two-tone">assignment</i>
      </section>
      <section id="rounded">
        <h2>Rounded</h2>
        <i class="material-icons-round">home</i>
        <i class="material-icons-round">assignment</i>
      </section>
      <section id="sharp">
        <h2>Sharp</h2>
        <i class="material-icons-sharp">home</i>
        <i class="material-icons-sharp">assignment</i>
      </section>
    </body>
    
    </html>

    Or view it on Codepen

    0 讨论(0)
  • 2020-11-28 18:39

    Put in head link to google styles

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
    

    and in body something like this

    <i class="material-icons-outlined">bookmarks</i>
    
    0 讨论(0)
  • 2020-11-28 18:44

    Somewhat hilariously, Google has made a font that works correctly in Safari but not in Chrome. Here's the https://codepen.io/anon/pen/zbavza

    <i class="material-icons-round red">warning</i>
    

    In reference to https://stackoverflow.com/a/54902967/4740291 and not being able to change the color using css.

    0 讨论(0)
提交回复
热议问题