LoginSignup
12
6

More than 5 years have passed since last update.

material icon で outlined のアイコンを使用する方法

Posted at

これは何

フォントとして読み込んで便利なアイコンとして使えるMaterial Iconについての小ネタ。
公式: https://material.io/tools/icons/?style=baseline

名称を指定したときにデフォルトだとFilledのアイコンが使われるが、どうやったらoutlinedのアイコンが使えるかというのを調べたことを書いておきます。

基本的な使い方

みためこんな感じのアイコン。bookを使います。画像はデフォルトのfilledのもの。
image.png

フォントとして読み込みます。

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

classに 指定します。

<i class="material-icons">book</i>

outlined のアイコンの使い方

みためこんな感じになるやつ。
image.png

公式ページからSVGとしてダウンロードして使ってもいいのですが、面倒なのでFilledと同じ方法で使えないのか?と思って調べてみたら、簡単な方法がありました。

以下のようにMaterial+Icons+Outlinedも読み込みます。

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

クラス名も -outlined をつけます。

<i class="material-icons-outlined">book</i>

もっと簡単な方法で使える方法?

error とか、よくある16個の図形は、フォントとして追加で読み込まないでクラス名もそのままで使えるとか。ただし、error_outline のようにアンダーバーで名前を変える。


<i class="material-icons">error_outline</i> 

参考: https://stackoverflow.com/questions/50303454/how-to-use-the-new-material-design-icon-themes-outlined-rounded-two-tone-and

12
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
6