LoginSignup
0
0

More than 1 year has passed since last update.

[Rails] [haml] link_toに文字とfontawesome両方を使って表示させる

Last updated at Posted at 2022-05-13

はじめに

hamlにてlink_toを使って文字の後ろにfontawesomeのアイコンを置きたかったのですが、調べてもなかなか見つからなかったので記事にしました。

写真

とても簡単だったので需要があるのかわかりませんがよろしくお願いします!
⚠fontawesomeが使える状態を前提としています。

結論

hamlの場合↓

posts/index.html.haml
= link_to users_path do
  こちらがリンクです
  %i.far.fa-hand-point-right

erbの場合↓

posts/index.html.erb
<%= link_to users_path do %>
  こちらがリンクです<i class="far fa-hand-point-right"></i>
<% end %>

もちろんアイコンを文字の手前に持っていきたければ<i class= " ~ ">の部分を先に記述するだけです。

最後に

簡単すぎましたがどなたかのお役に立てれば嬉しいです。
閲覧頂きましてありがとうございました🐎!

0
0
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
0
0