@@ -16,7 +16,6 @@ Installation
16
16
17
17
$ composer require symfony/ux-icons
18
18
19
-
20
19
SVG Icons
21
20
---------
22
21
@@ -89,40 +88,25 @@ Icon Sets
89
88
90
89
There are many icon sets available, each with their own unique style and set of
91
90
icons, providing a wide range of icons for different purposes, while maintaining
92
- a consistent look and feel across your application.
93
-
94
- With more than 200,000 icons available, you can find the perfect icon for your
95
- project. Here are some of the most popular icon sets available:
96
-
97
- ========================= ======= ========== =========== =================
98
- Icon Set Icons License Prefix Example
99
- ========================= ======= ========== =========== =================
100
- `Bootstrap Icons `_ 2000 MIT bi bi:check
101
- `Boxicons `_ 1700 MIT bx bx:check
102
- `Flowbite `_ 1000 MIT flowbite flowbite:check
103
- `FontAwesome Icons `_ 7000 CC BY 4.0 fa6-regular fa6-regular:check
104
- `Heroicons `_ 300 MIT heroicons heroicons:check
105
- `Iconoir `_ 1500 MIT iconoir iconoir:check
106
- `Ionicons `_ 1300 MIT ion ion:check
107
- `Lucide Icons `_ 1500 MIT lucide lucide:check
108
- `Material Design Icons `_ 5000 Apache 2 mdi mdi:check
109
- `Octicons `_ 600 MIT octicon octicon:check
110
- `Phosphor Icons `_ 7000 MIT ph ph:check
111
- `Tabler Icons `_ 5200 MIT tabler tabler:check
112
- ========================= ======= ========== =========== =================
113
-
114
- - `Bootstrap Icons <https://icons.getbootstrap.com/ >`_
115
- - `Boxicons <https://boxicons.com/ >`_
116
- - `Flowbite <https://github.com/themesberg/flowbite >`_
117
- - `FontAwesome Icons <https://github.com/FortAwesome/Font-Awesome >`_
118
- - `Heroicons <https://github.com/tailwindlabs/heroicons >`_
119
- - `Iconoir <https://github.com/iconoir-icons/iconoir >`_
120
- - `Ionicons <https://github.com/ionic-team/ionicons >`_
121
- - `Lucide Icons <https://github.com/lucide-icons/lucide >`_
122
- - `Material Design Icons <https://github.com/google/material-design-icons >`_
123
- - `Octicons <https://github.com/primer/octicons/ >`_
124
- - `Phosphor Icons <https://github.com/phosphor-icons/homepage >`_
125
- - `Tabler Icons <https://github.com/tabler/tabler-icons >`_
91
+ a consistent look and feel across your application. Here are some of the most
92
+ popular icon sets available:
93
+
94
+ ======================== ======= ========== =============== =====================
95
+ Icon Set Icons License Prefix Example
96
+ ======================== ======= ========== =============== =====================
97
+ `Bootstrap Icons `_ 2000 MIT ``bi `` ``bi:check ``
98
+ `Boxicons `_ 1700 MIT ``bx `` ``bx:check ``
99
+ `Flowbite `_ 1000 MIT ``flowbite `` ``flowbite:check ``
100
+ `FontAwesome Icons `_ 7000 CC BY 4.0 ``fa6-regular `` ``fa6-regular:check ``
101
+ `Heroicons `_ 300 MIT ``heroicons `` ``heroicons:check ``
102
+ `Iconoir `_ 1500 MIT ``iconoir `` ``iconoir:check ``
103
+ `Ionicons `_ 1300 MIT ``ion `` ``ion:check ``
104
+ `Lucide Icons `_ 1500 MIT ``lucide `` ``lucide:check ``
105
+ `Material Design Icons `_ 5000 Apache 2 ``mdi `` ``mdi:check ``
106
+ `Octicons `_ 600 MIT ``octicon `` ``octicon:check ``
107
+ `Phosphor Icons `_ 7000 MIT ``ph `` ``ph:check ``
108
+ `Tabler Icons `_ 5200 MIT ``tabler `` ``tabler:check ``
109
+ ======================== ======= ========== =============== =====================
126
110
127
111
To see the full list of available icon sets, visit `ux.symfony.com/icons `_.
128
112
@@ -180,7 +164,6 @@ a subdirectory, the *name* will be ``subdirectory:icon_name``.
180
164
│ └─ ...
181
165
└─ ...
182
166
183
-
184
167
Icons On-Demand
185
168
~~~~~~~~~~~~~~~
186
169
@@ -190,10 +173,6 @@ from many different sets. This package provides a way to include any icon found
190
173
`ux.symfony.com/icons `_ has a huge searchable repository of icons from many
191
174
different sets. This package provides a way to include any icon found on this
192
175
site *on-demand *:
193
- 1. Visit `ux.symfony.com/icons `_ and search for an icon
194
- you'd like to use. Once you find one you like, copy one of the code snippets provided.
195
- 2. Paste the snippet into your Twig template and the icon will be automatically fetched (and cached).
196
- 3. That's it!
197
176
198
177
1. Visit `ux.symfony.com/icons `_ and search for an icon you'd like to use. Once
199
178
you find one you like, copy one of the code snippets provided.
@@ -286,19 +265,6 @@ HTML Syntax
286
265
287
266
``symfony/ux-twig-component `` is required to use the HTML syntax.
288
267
289
- HTML Attributes
290
- ~~~~~~~~~~~~~~~
291
-
292
- The second argument of the ``ux_icon `` function is an array of attributes to add to the icon.
293
-
294
- .. code-block :: twig
295
-
296
- {# renders "user-profile.svg" with class="w-4 h-4" #}
297
- {{ ux_icon('user-profile', {class: 'w-4 h-4'}) }}
298
-
299
- {# renders "user-profile.svg" with class="w-4 h-4" and aria-hidden="true" #}
300
- {{ ux_icon('user-profile', {class: 'w-4 h-4', 'aria-hidden': true}) }}
301
-
302
268
Default Attributes
303
269
~~~~~~~~~~~~~~~~~~
304
270
@@ -325,60 +291,39 @@ Now, all icons will have the ``fill`` attribute set to ``currentColor`` by defau
325
291
Accessibility
326
292
-------------
327
293
328
- Icons are a used to add visual elements to your website, but they can be a challenge
329
- for accessibility.
330
-
331
- According to the `W3C <https://design-system.w3.org/styles/svg-icons.html >`_, there are
332
- three methods to improve icons accessibility, depending on the context:
333
-
334
- * **Decorative **: Icons that are purely decorative and do not convey any meaning or function.
335
- * **Informative **: Icons that convey information or a function.
336
- * **Functional **: Icons that are interactive and perform a function.
337
-
338
- Decorative Icons
339
- ~~~~~~~~~~~~~~~~
340
-
341
- If the icon is purely decorative and does not convey any meaning or function, it should be
342
- hidden from screen readers using the ``aria-hidden `` attribute.
343
-
344
- .. code-block :: html+twig
345
-
346
- <a href="/profile">
347
- {{ ux_icon('user-profile', {class: 'w-4 h-4', 'aria-hidden': true}) }}
348
- Back to profile
349
- </a>
350
-
351
- Informative Icons
352
- ~~~~~~~~~~~~~~~~~
353
-
354
- If the icon conveys information or a function, it should be given a text alternative that presents
355
- the same content or function, so that it can fulfill the same purpose.
294
+ Icons add visual elements to your website and they can be a challenge for accessibility.
295
+ According to the `W3C guide about SVG icon accessibility `_, there are
296
+ three methods to improve icons accessibility, depending on the context.
356
297
357
- .. code-block :: twig
358
-
359
- Today's weather:
360
- {{ ux_icon('cloud-rain', {'aria-label': 'Rainy weather'}) }}
298
+ **Decorative icons **
299
+ They are purely decorative and do not convey any meaning or function. They
300
+ should be hidden from screen readers using the ``aria-hidden `` attribute:
361
301
362
- Functional Icons
363
- ~~~~~~~~~~~~~~~~
302
+ .. code-block :: html+twig
364
303
365
- If the icon is interactive and performs a function, it should be given a text alternative that
366
- presents the same content or function, so that it can fulfill the same purpose.
367
-
368
- .. code-block :: twig
304
+ <a href="/profile">
305
+ {{ ux_icon('user-profile', {class: 'w-4 h-4', 'aria-hidden': true}) }}
306
+ Back to profile
307
+ </a>
369
308
370
- {{ ux_icon('user-profile', {class: 'w-4 h-4', 'aria-label': 'User Profile'}) }}
309
+ **Informative icons **
310
+ They convey information or a function. They should define a text alternative
311
+ that presents the same content or function via the ``aria-label `` attribute
312
+ used by screen readers and other assistive technologies:
371
313
372
- .. note ::
314
+ .. code-block :: twig
373
315
374
- The `` aria-label `` attribute is used to provide a label for the icon. It is read by
375
- screen readers and other assistive technologies.
316
+ Today's weather:
317
+ {{ ux_icon('cloud-rain', {'aria-label': 'Rainy weather'}) }}
376
318
377
- .. note ::
319
+ **Functional icons **
320
+ They are interactive and perform a function. They should define a text alternative
321
+ that presents the same content or function via the ``aria-label `` attribute
322
+ used by screen readers and other assistive technologies:
378
323
379
- The ``aria-hidden `` attribute is used to hide the icon from screen readers and other
380
- assistive technologies.
324
+ .. code-block :: twig
381
325
326
+ {{ ux_icon('user-profile', {class: 'w-4 h-4', 'aria-label': 'User Profile'}) }}
382
327
383
328
Performance
384
329
-----------
@@ -398,7 +343,6 @@ in the future. Additionally, the cache warming process will take significantly l
398
343
many _on-demand _ icons. You can think of importing the icon as *locking it * (similar to how
399
344
``composer.lock `` _locks_ your dependencies).
400
345
401
-
402
346
Icon Caching
403
347
~~~~~~~~~~~~
404
348
@@ -441,9 +385,9 @@ This command looks in all your Twig templates for ``ux_icon()`` calls and
441
385
TwigComponent
442
386
~~~~~~~~~~~~~
443
387
444
- The ``ux_icon `` function is optimized to be as fast as possible. To deliver the same level
445
- of performance with the TwigComponent (``<twig:UX:Icon name="..." /> ``), the TwigComponent
446
- usual overhead is reduced to the bare minimum, immediately calling the IconRenderer and
388
+ The ``ux_icon() `` function is optimized to be as fast as possible. To deliver the
389
+ same level of performance when using the HTML syntax (``<twig:UX:Icon name="..." /> ``),
390
+ the TwigComponent overhead is reduced by calling the IconRenderer immediately and
447
391
returning the HTML output.
448
392
449
393
.. warning ::
@@ -460,7 +404,6 @@ returning the HTML output.
460
404
<path fill="currentColor" d="M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"/>
461
405
</svg>
462
406
463
-
464
407
Configuration
465
408
-------------
466
409
@@ -473,7 +416,6 @@ the ``ux_icons`` key in your application configuration.
473
416
ux_icons :
474
417
{# ... # }
475
418
476
-
477
419
Debugging Configuration
478
420
~~~~~~~~~~~~~~~~~~~~~~~
479
421
@@ -520,3 +462,16 @@ Learn more
520
462
.. _`ux.symfony.com/icons` : https://ux.symfony.com/icons
521
463
.. _`Iconify` : https://iconify.design
522
464
.. _`symfony/asset-mapper` : https://symfony.com/doc/current/frontend/asset_mapper.html
465
+ .. _`W3C guide about SVG icon accessibility` : https://design-system.w3.org/styles/svg-icons.html#svg-accessibility
466
+ .. _`Bootstrap Icons` : https://icons.getbootstrap.com/
467
+ .. _`Boxicons` : https://boxicons.com/
468
+ .. _`Flowbite` : https://github.com/themesberg/flowbite
469
+ .. _`FontAwesome Icons` : https://github.com/FortAwesome/Font-Awesome
470
+ .. _`Heroicons` : https://github.com/tailwindlabs/heroicons
471
+ .. _`Iconoir` : https://github.com/iconoir-icons/iconoir
472
+ .. _`Ionicons` : https://github.com/ionic-team/ionicons
473
+ .. _`Lucide Icons` : https://github.com/lucide-icons/lucide
474
+ .. _`Material Design Icons` : https://github.com/google/material-design-icons
475
+ .. _`Octicons` : https://github.com/primer/octicons/
476
+ .. _`Phosphor Icons` : https://github.com/phosphor-icons/homepage
477
+ .. _`Tabler Icons` : https://github.com/tabler/tabler-icons
0 commit comments