Current section

Files

Jump to
corex lib components heroicon.ex
Raw

lib/components/heroicon.ex

defmodule Corex.Heroicon do
@moduledoc """
Renders a Heroicon.
"""
@doc type: :component
use Phoenix.Component
@doc """
Renders a [Heroicon](https://heroicons.com).
Heroicons come in three styles – outline, solid, and mini.
By default, the outline style is used, but solid and mini may
be applied by using the `-solid` and `-mini` suffix.
You can customize the size and colors of the icons by setting
width, height, and background color classes.
Icons are extracted from the `deps/heroicons` directory and bundled within
your compiled app.css by the plugin in `assets/vendor/heroicons.js`.
## Examples
<.heroicon name="hero-x-mark" />
<.heroicon name="hero-arrow-path" class="ml-1 size-3 motion-safe:animate-spin" />
"""
attr(:name, :string, required: true)
attr(:class, :any, default: "")
def heroicon(%{name: "hero-" <> _} = assigns) do
~H"""
<span class={[@name, @class]} />
"""
end
end