Bootstrap Icons
Bootstrap Icons is a "free, high quality, open source icon library with over 1,300 icons". This package gives you Elixir functions to drop Bootstrap Icons into your HTML, styled with arbitrary classes.
Bootstrap Icons are designed by Bootstrap Team
Installation
Add Bootstrap Icons to your mix.exs
:
defp deps do
[
{:bootstrap_icons, "~> 0.1.0"}
]
end
After that, run mix deps.get
.
Usage
The icons are in BootstrapIcons
. You can get an icon by name
<%= Bootstrap.Icons.alarm() %>
and style it with some classes
<%= Bootstrap.Icons.alarm(class: "text-danger", width: 32, height: 32) %>
Note these functions return Phoenix.HTML.Safe
iodata:
iex(1)> Bootstrap.Icons.alarm()
{:safe,
["<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\"", #...
iex(2)> Bootstrap.Icons.alarm() |> Phoenix.HTML.safe_to_string
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\">\n ..."
For a full list of icons see the docs or icons.getbootstrap.com.
Credits
This project is heavily based on the fantastic heroicons_elixir package by Max Veytsman. I just replaced the Heroicons with the Bootstrap icons and patched some parts to support the specialities of the Bootstrap SVG icons.