@@ -12,14 +12,13 @@ composer require husseinalhammad/fontawesome-svg
12
12
13
13
Or you can download the ` FontAwesomeSVG.php ` file and include it manually.
14
14
15
-
16
15
## Usage
17
16
18
17
### Files
19
18
20
- * Download Font Awesome (Free or Pro)
21
- * Get the folder ` advanced-options/raw-svg ` and place it in your project
22
- * Add ` svg-with-js/css/fa-svg-with-js ` to your document (or write your own CSS)
19
+ - Download Font Awesome (Free or Pro)
20
+ - Get the folder ` advanced-options/raw-svg ` and place it in your project
21
+ - Add ` svg-with-js/css/fa-svg-with-js ` to your document (or write your own CSS)
23
22
24
23
### Examples
25
24
@@ -66,15 +65,89 @@ echo $FA->get_svg('fas fa-file', [
66
65
]);
67
66
```
68
67
69
- | Option | What it means |
70
- | -----------------------| --------------------------------------------------------------------------|
71
- | class | Adds classes to the SVG tag |
72
- | default_class | If set to ` false ` , the default CSS class won't be added to the SVG tag. Deafult: ` true ` . |
73
- | title | Adds a ` <title> ` inside the SVG tag for semantic icons |
74
- | title_id | Adds an ` id ` attribute to ` <title> ` and adds ` aria-labelledby ` on the SVG tag with the same value |
75
- | role | The value of the ` role ` attribute in the SVG tag. Default: ` img ` |
76
- | fill | The value of the ` fill ` attribute in the ` <path> ` inside the SVG. Default: ` currentColor ` |
68
+ Customise duotone icons:
69
+
70
+ ``` php
71
+ echo $FA->get_svg('fad fa-laugh-wink', [
72
+ 'primary' => [
73
+ 'fill' => '#e64980',
74
+ ],
75
+ 'secondary' => [
76
+ 'fill' => '#fcc417',
77
+ 'opacity' => '1',
78
+ ],
79
+ ]);
80
+ ```
81
+
82
+ | Option | What it means |
83
+ | ------------- | ------------------------------------------------------------------------------------------------- |
84
+ | class | Adds classes to the SVG tag |
85
+ | default_class | If set to ` false ` , the default CSS class won't be added to the SVG tag. Deafult: ` true ` . |
86
+ | inline_style | Whether to add duotone styles as inline style to the ` <svg> ` tag. Deafult: ` true ` . |
87
+ | title | Adds a ` <title> ` inside the SVG tag for semantic icons |
88
+ | title_id | Adds an ` id ` attribute to ` <title> ` and adds ` aria-labelledby ` on the SVG tag with the same value |
89
+ | role | The value of the ` role ` attribute in the SVG tag. Default: ` img ` |
90
+ | fill | The value of the ` fill ` attribute in the ` <path> ` inside the SVG. Default: ` currentColor ` |
91
+ | primary | Duotone primary options (see table below) |
92
+ | secondary | Duotone secondary options (see table below) |
93
+
94
+ ## Duotone
95
+
96
+ > Requires ** v5.10.0** or greater, and a FontAwesome Pro license
97
+
98
+ ### options
99
+
100
+ If ` inline_style ` is enabled, the value of ` fill ` and ` opacity ` are also used in the inline style on ` <svg> ` tag.
101
+
102
+ | Option | What it means |
103
+ | ------- | ----------------------------------------------------------------------------------------- |
104
+ | fill | The value of the ` fill ` attribute in the ` <path> ` inside the SVG. Default: ` currentColor ` |
105
+ | opacity | The value of the ` opacity ` attribute in the ` <path> ` inside the SVG. |
106
+
107
+ ### Examples:
108
+
109
+ Single colour:
110
+
111
+ ``` php
112
+ echo $FA->get_svg('fad fa-laugh-wink', [
113
+ 'fill' => '#e64980',
114
+ ]);
115
+ ```
116
+
117
+ Swapping Layer Opacity:
77
118
119
+ ``` php
120
+ echo $FA->get_svg('fad fa-laugh-wink', [
121
+ 'fill' => '#e64980',
122
+ 'class' => 'fa-swap-opacity',
123
+ ]);
124
+ ```
125
+
126
+ Single colour with custom opacity:
127
+
128
+ ``` php
129
+ echo $FA->get_svg('fad fa-laugh-wink', [
130
+ 'fill' => '#e64980',
131
+ 'secondary' => [
132
+ 'opacity' => '0.2',
133
+ ],
134
+ ]);
135
+ ```
136
+
137
+ Custom colours and opacity:
138
+
139
+ ``` php
140
+ echo $FA->get_svg('fad fa-laugh-wink', [
141
+ 'primary' => [
142
+ 'fill' => '#e64980',
143
+ 'opacity' => '0.5',
144
+ ],
145
+ 'secondary' => [
146
+ 'fill' => '#fcc417',
147
+ 'opacity' => '1',
148
+ ],
149
+ ]);
150
+ ```
78
151
79
152
## Accessibility
80
153
@@ -83,7 +156,6 @@ The below is implemented based on:
83
156
- Font Awesome's [ Accessibility docs] ( https://fontawesome.com/how-to-use/on-the-web/other-topics/accessibility )
84
157
- Heather Migliorisi's article on CSS-Tricks [ Accessible SVGs] ( https://css-tricks.com/accessible-svgs/ )
85
158
86
-
87
159
### ` role ` attribute
88
160
89
161
` role="img" ` is added to the SVG tag by default:
@@ -92,7 +164,6 @@ The below is implemented based on:
92
164
<svg role =" img" ></svg >
93
165
```
94
166
95
-
96
167
### ` <title> ` , ` aria-labelledby `
97
168
98
169
You can set a ` <title> ` , an ` id ` for the ` <title> ` and the ` aria-labelledby ` attribute will be added automatically:
@@ -106,14 +177,13 @@ echo $FA->get_svg('fas fa-file', [
106
177
107
178
``` html
108
179
<svg aria-labelledby =" file-id" >
109
- <title id =" file-id" >File</title >
180
+ <title id =" file-id" >File</title >
110
181
</svg >
111
182
```
112
183
113
-
114
184
### ` aria-* ` attributes
115
185
116
- You can add any aria-* attribute to the SVG tag:
186
+ You can add any aria-\ * attribute to the SVG tag:
117
187
118
188
``` php
119
189
echo $FA->get_svg('fas fa-file', [
@@ -125,7 +195,6 @@ echo $FA->get_svg('fas fa-file', [
125
195
<svg aria-label =" File" ></svg >
126
196
```
127
197
128
-
129
198
### ` aria-hidden ` attribute
130
199
131
200
` aria-hidden="true" ` is added to the SVG tag by default unless ` <title id=""> ` (and ` aria-labelledby ` ) or ` aria-label ` is set.
@@ -136,4 +205,4 @@ echo $FA->get_svg('fas fa-file');
136
205
137
206
``` html
138
207
<svg aria-hidden =" true" ></svg >
139
- ```
208
+ ```
0 commit comments