1
- # Symfony UX Icons
1
+ # UX Icons
2
2
3
- Tools for embedding SVG icons in your Twig templates.
3
+ Renders local and remote SVG icons in your Twig templates.
4
4
5
5
``` twig
6
6
{{ ux_icon('mdi:symfony', {class: 'w-4 h-4'}) }}
@@ -11,120 +11,30 @@ Tools for embedding SVG icons in your Twig templates.
11
11
<svg viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4"><path fill="currentColor" d="M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"/></svg>
12
12
```
13
13
14
- ## Installation
14
+ Want a demo? Check out https://ux.symfony.com/ux-icons .
15
15
16
- ``` bash
17
- composer require symfony/ux-icons
18
- ```
19
-
20
- ## Icons?
21
-
22
- No icons are provided by this package but there are several ways to include and render icons.
23
-
24
- ### Local SVG Icons
25
-
26
- Add your svg icons to the ` assets/icons/ ` directory and commit them.
27
- The name of the file is used as the _ name_ of the icon (` name.svg ` will be named ` name ` ).
28
- If located in a subdirectory, the _ name_ will be ` sub-dir:name ` .
29
-
30
- ### Icons _ On-Demand_
31
-
32
- [ ux.symfony.com/icons] ( https://ux.symfony.com/icons ) has a huge searchable repository of icons
33
- from many different sets. This package provides a way to include any icon found on this site _ on-demand_ .
34
-
35
- 1 . Visit [ ux.symfony.com/icons] ( https://ux.symfony.com/icons ) and search for an icon
36
- you'd like to use. Once you find one you like, copy one of the code snippets provided.
37
- 2 . Paste the snippet into your twig template and the icon will be automatically fetched (and cached).
38
- 3 . That's it!
39
-
40
- This works by using [ Iconify's] ( https://iconify.design ) API (to which [ ux.symfony.com/icons] ( https://ux.symfony.com/icons )
41
- is a frontend for) to fetch the icon and render it in place. This icon is then cached for future requests
42
- for the same icon.
43
-
44
- > [ !NOTE]
45
- > [ Local SVG Icons] ( #local-svg-icons ) of the same name will have precedence over _ on-demand_ icons.
46
-
47
- #### Import Command
48
-
49
- You can import any icon from [ ux.symfony.com/icons] ( https://ux.symfony.com/icons ) to your local
50
- directory using the ` ux:icons:import ` command:
51
-
52
- ``` bash
53
- bin/console ux:icons:import flowbite:user-solid # saved as `flowbite/user-solid.svg` and name is `flowbite:user-solid`
54
-
55
- # import several at a time
56
- bin/console ux:icons:import flowbite:user-solid flowbite:home-solid
57
- ```
58
-
59
- > [ !NOTE]
60
- > Imported icons must be committed to your repository.
61
-
62
- #### On-Demand VS Import
63
-
64
- While _ on-demand_ icons are great during development, they require http requests to fetch the icon
65
- and always use the _ latest version_ of the icon. It's possible the icon could change or be removed
66
- in the future. Additionally, the cache warming process will take significantly longer if using
67
- many _ on-demand_ icons. You can think of importing the icon as _ locking it_ (similar to how
68
- ` composer.lock ` _ locks_ your dependencies).
69
-
70
- ## Usage
16
+ ** This repository is a READ-ONLY sub-tree split** . See
17
+ https://github.com/symfony/ux to create issues or submit pull requests.
71
18
72
- ``` twig
73
- {{ ux_icon('user-profile', {class: 'w-4 h-4'}) }} <!-- renders "user-profile.svg" -->
74
-
75
- {{ ux_icon('sub-dir:user-profile', {class: 'w-4 h-4'}) }} <!-- renders "sub-dir/user-profile.svg" (sub-directory) -->
76
-
77
- {{ ux_icon('flowbite:user-solid') }} <!-- renders "flowbite:user-solid" from ux.symfony.com -->
78
- ```
79
-
80
- ### HTML Syntax
81
-
82
- > [ !NOTE]
83
- > ` symfony/ux-twig-component ` is required to use the HTML syntax.
84
-
85
- ``` html
86
- <twig:UX:Icon name =" user-profile" class =" w-4 h-4" /> <!-- renders "user-profile.svg" -->
87
-
88
- <twig:UX:Icon name =" sub-dir:user-profile" class =" w-4 h-4" /> <!-- renders "sub-dir/user-profile.svg" (sub-directory) -->
89
-
90
- <twig:UX:Icon name =" flowbite:user-solid" /> <!-- renders "flowbite:user-solid" from ux.symfony.com -->
91
- ```
92
-
93
- ## Caching
94
-
95
- To avoid having to parse icon files on every request, icons are cached.
19
+ ## Sponsor
96
20
97
- In production, you can pre-warm the cache by running the following command:
98
-
99
- ``` bash
100
- bin/console ux:icons:warm-cache
101
- ```
21
+ The Symfony UX packages are [ backed] [ 1 ] by [ Mercure.rocks] [ 2 ] .
102
22
103
- This command looks in all your twig templates for ` ux_icon ` calls and caches the icons it finds.
23
+ Create real-time experiences in minutes! Mercure.rocks provides a realtime API service
24
+ that is tightly integrated with Symfony: create UIs that update in live with UX Turbo,
25
+ send notifications with the Notifier component, expose async APIs with API Platform and
26
+ create low level stuffs with the Mercure component. We maintain and scale the complex
27
+ infrastructure for you!
104
28
105
- > [ !NOTE]
106
- > During development, if you modify an icon, you will need to clear the cache (` bin/console cache:clear ` )
107
- > to see the changes.
29
+ Help Symfony by [ sponsoring] [ 3 ] its development!
108
30
109
- > [ !TIP]
110
- > If using ` symfony/asset-mapper ` , the cache is warmed automatically when running ` asset-map:compile ` .
31
+ ## Resources
111
32
112
- ## Full Default Configuration
33
+ - [ Documentation] ( https://symfony.com/bundles/ux-icons/current/index.html )
34
+ - [ Report issues] ( https://github.com/symfony/ux/issues ) and
35
+ [ send Pull Requests] ( https://github.com/symfony/ux/pulls )
36
+ in the [ main Symfony UX repository] ( https://github.com/symfony/ux )
113
37
114
- ``` yaml
115
- ux_icons :
116
- # The local directory where icons are stored.
117
- icon_dir : ' %kernel.project_dir%/assets/icons'
118
-
119
- # Default attributes to add to all icons.
120
- default_icon_attributes :
121
- # Default:
122
- fill : currentColor
123
-
124
- # Configuration for the "on demand" icons powered by Iconify.design.
125
- iconify :
126
- enabled : true
127
-
128
- # The endpoint for the Iconify API.
129
- endpoint : ' https://api.iconify.design'
130
- ` ` `
38
+ [ 1 ] : https://symfony.com/backers
39
+ [ 2 ] : https://mercure.rocks
40
+ [ 3 ] : https://symfony.com/sponsor
0 commit comments