Refer to the readme for usage instructions.
All functions of this module are internal. They are only used by
mix ex_icon.gen.icons.
Summary
Types
@type options() :: [ icons: [binary()] | term(), exclude: [binary()], provider: atom(), version: binary(), path: binary(), module_path: binary(), module_name: atom(), variants: [atom()], global_attrs: boolean() | keyword(), attrs: term() ]
The options that every icon set in .ex_icon.exs takes.
:icons- Required. Either a list of icon names you want to generate (e.g.["arrow-left"]), or:allif you want to generate all available icons.:exclude(list ofString.t/0) - Icon names to skip, which is mostly useful in combination withicons: :all. Example:["1password"]. The default value is[].:provider(atom/0) - A module implementing theExIcon.Providerbehaviour. Required withversion, unlesspathis set.:version(String.t/0) - The release version of the icon library.:path(String.t/0) - Path to a folder that contains SVG files. Cannot be used together withproviderandversion.:module_path(String.t/0) - Required. The destination path of the icon module that ExIcon will generate for you. Example:"lib/my_app_web/components/lucide.ex".:module_name(atom/0) - Required. The name of the generated module. Example:MyApp.Components.Lucide.:variants(list ofatom/0) - The variants of the icon library to generate, for providers that implementExIcon.Provider.variants/1. Example:[:outline, :solid].Each variant is generated into a separate module, with the variant appended to
module_nameandmodule_path.Example:
module_name:MyApp.Components.Heroiconsmodule_path:"lib/my_app_web/components/heroicons.ex"- generated module name for the
:outlinevariant:MyApp.Components.Heroicons.Outline - path of the module for the
:outlinevariant:lib/my_app_web/components/heroicons/outline.ex
Defaults to an empty list, which generates a single module from
ExIcon.Provider.svg_folder/1.Not supported if
pathis set.The default value is
[].:global_attrs- Adds anattr :rest, :globalto the generated components, so that they accept the global HTML attributes, such asid,class,phx-clickanddata-*.Set to
true, or to a keyword list with thedefaultandincludeoptions ofattr. Example:[default: %{"class" => "size-6"}, include: ["fill"]].The attributes that are passed to a component are written before the ones of the SVG file, so that they take precedence.
The default value is
false.:attrs(list ofString.t/0or{t:String.t/0, keyword}) - Configures the attributes of the<svg>element. Each entry is either an attribute name, or a tuple with the attribute name and options.If a list entry is a string (e.g.
"stroke"), the value is replaced with a HEEx variable and a component attribute is added.If a list entry is a tuple, the following options are supported:
default({"stroke-width", default: "1.5"}) - Sets thedefaultoption onattr.values({"stroke-linecap", values: ["square", "round"]}) - Sets thevaluesoption onattr. Generation fails if the value in an SVG file is not among the values.required({"stroke-width", required: true}) - Sets therequiredoption onattr.fixed({"fill", fixed: "none"}) - Sets a fixed value for the SVG attribute without adding a component attribute.
Attributes that are not present in the original SVG file are added, as long as a
:default,:fixed,:valuesor:requiredis given. Attribute names are matched case-insensitively, and each attribute may only be configured once.If an attribute is added but neither the SVG file nor
:defaultprovides a value,required: trueis added to the component attribute.An
aria-hiddenattribute is always added, and can be configured like any other attribute. Without configuration, the value of the SVG file is kept, or"true"is used if it does not have the attribute.The default value is
[].