You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Access 200,000+ icons from 150+ icon sets. Browse available icons at [icon-sets.iconify.design](https://icon-sets.iconify.design).
5
+
Inline [Iconify](https://iconify.design) SVGs for Phoenix and LiveView. Write a normal Phoenix component, let the compiler discover the icons you use, and ship only those icons with your app.
6
6
7
-
## Features
7
+
```heex
8
+
<.icon name="lucide:settings" class="size-5" />
9
+
```
10
+
11
+
PhoenixIconify gives Phoenix apps access to 200,000+ icons from 150+ icon sets without a client-side icon runtime. Browse icons at [icon-sets.iconify.design](https://icon-sets.iconify.design).
12
+
13
+
## Why PhoenixIconify
14
+
15
+
Most Iconify integrations load icons in JavaScript. PhoenixIconify keeps icons on the server:
16
+
17
+
- Icons are discovered from HEEx at compile time
18
+
- Only icons you use are fetched and stored
19
+
- Rendering is plain inline SVG
20
+
- No browser-side icon loader
21
+
- Works with LiveView diffs and `phx-*` attributes
22
+
- Dynamic icons can be pre-registered in config
8
23
9
-
-**Compile-time discovery** - Icons are automatically detected from your templates
10
-
-**On-demand fetching** - Only icons you use are downloaded
11
-
-**Zero runtime overhead** - Icons are embedded at compile time
12
-
-**LiveView optimized** - Minimal diffs, only attributes change
24
+
It pairs naturally with Tailwind and Volt-powered Phoenix projects:
25
+
26
+
```heex
27
+
<button class="inline-flex items-center gap-2">
28
+
<.icon name="lucide:settings" class="size-4" />
29
+
Settings
30
+
</button>
31
+
```
13
32
14
33
## Installation
15
34
16
-
Add `phoenix_iconify` to your list of dependencies in `mix.exs`:
35
+
Add the dependency:
17
36
18
37
```elixir
19
38
defdepsdo
@@ -23,74 +42,90 @@ def deps do
23
42
end
24
43
```
25
44
26
-
Add the compiler to your project:
45
+
Add the compiler:
27
46
28
47
```elixir
29
48
defprojectdo
30
49
[
31
-
compilers:Mix.compilers() ++ [:phoenix_iconify],
32
-
# ...
50
+
compilers:Mix.compilers() ++ [:phoenix_iconify]
33
51
]
34
52
end
35
53
```
36
54
37
-
## Usage
38
-
39
-
Import the component in your web module (`lib/my_app_web.ex`):
Iconify transformations are supported for aliases and at render time:
126
+
## Transformations
127
+
128
+
Iconify aliases can include transformations, and you can transform at render time:
94
129
95
130
```heex
96
131
<.icon name="lucide:arrow-right" rotate={1} />
@@ -99,84 +134,86 @@ Iconify transformations are supported for aliases and at render time:
99
134
<.icon name="lucide:arrow-right" v_flip />
100
135
```
101
136
102
-
## Icon Names
137
+
## How it works
103
138
104
-
Icons use the format `prefix:icon-name`:
139
+
1. You write `<.icon name="lucide:settings" />`
140
+
2. The `:phoenix_iconify` compiler scans HEEx and `~H` sigils
141
+
3. Literal icon names are collected
142
+
4. Missing icons are fetched through Iconify
143
+
5. A JSON manifest is written to `priv/iconify/manifest.json`
144
+
6. At runtime, the component reads icons from the manifest and renders inline SVG
105
145
106
-
-`heroicons:user` - Heroicons user icon
107
-
-`heroicons:user-solid` - Heroicons solid user
108
-
-`lucide:home` - Lucide home icon
109
-
-`mdi:account` - Material Design Icons account
146
+
There is no client-side icon runtime and no JavaScript bundle impact.
110
147
111
-
Browse all icons at [icon-sets.iconify.design](https://icon-sets.iconify.design).
148
+
## Dynamic icons
112
149
113
-
## Configuration
150
+
Compile-time discovery only works for literal names. If an icon name comes from assigns, a database, or user configuration, register the possible values:
114
151
115
152
```elixir
116
153
# config/config.exs
117
154
config :phoenix_iconify,
118
-
# Pre-register icons for dynamic usage (e.g., icons from database)
For projects created with Volt, use `phoenix_iconify` when you want server-rendered, compile-time embedded SVGs:
210
+
For projects created with [Volt](https://hex.pm/packages/volt), PhoenixIconify is the server-rendered option:
174
211
175
212
```heex
176
213
<.icon name="lucide:settings" class="size-5" />
177
214
```
178
215
179
-
This does not use Volt's JavaScript pipeline. If you want client-side Iconify components instead, use the official npm packages (`iconify-icon`, `@iconify/react`, `@iconify/vue`, etc.) through Volt's normal package handling.
216
+
It does not use Volt's JavaScript pipeline. If you want client-side icon components instead, use the official npm packages (`iconify-icon`, `@iconify/react`, `@iconify/vue`, etc.) through Volt's normal package handling.
0 commit comments