@@ -78,6 +78,62 @@ echo $FA->get_svg('fas fa-file', [
78
78
79
79
## Accessibility
80
80
81
- * ` role="img" ` is added to the SVG tag by default
82
- * ` aria-hidden="true" ` is added to the SVG tag by default unless a ` <title> ` is set
83
- * You can add ` aria-labelledby ` to the SVG tag and ` id ` to ` <title> `
81
+ The below is implemented based on:
82
+
83
+ - Font Awesome's [ Accessibility docs] ( https://fontawesome.com/how-to-use/on-the-web/other-topics/accessibility )
84
+ - Heather Migliorisi's article on CSS-Tricks [ Accessible SVGs] ( https://css-tricks.com/accessible-svgs/ )
85
+
86
+
87
+ ### ` role ` attribute
88
+
89
+ ` role="img" ` is added to the SVG tag by default:
90
+
91
+ ``` html
92
+ <svg role =" img" ></svg >
93
+ ```
94
+
95
+
96
+ ### ` <title> ` , ` aria-labelledby `
97
+
98
+ You can set a ` <title> ` , an ` id ` for the ` <title> ` and the ` aria-labelledby ` attribute will be added automatically:
99
+
100
+ ``` php
101
+ echo $FA->get_svg('fas fa-file', [
102
+ 'title' => 'File',
103
+ 'title_id' => 'file-id',
104
+ ]);
105
+ ```
106
+
107
+ ``` html
108
+ <svg aria-labelledby =" file-id" >
109
+ <title id =" file-id" >File</title >
110
+ </svg >
111
+ ```
112
+
113
+
114
+ ### ` aria-* ` attributes
115
+
116
+ You can add any aria-* attribute to the SVG tag:
117
+
118
+ ``` php
119
+ echo $FA->get_svg('fas fa-file', [
120
+ 'aria-label' => 'File',
121
+ ]);
122
+ ```
123
+
124
+ ``` html
125
+ <svg aria-label =" File" ></svg >
126
+ ```
127
+
128
+
129
+ ### ` aria-hidden ` attribute
130
+
131
+ ` aria-hidden="true" ` is added to the SVG tag by default unless ` <title id=""> ` or ` aria-label ` is set.
132
+
133
+ ``` php
134
+ echo $FA->get_svg('fas fa-file');
135
+ ```
136
+
137
+ ``` html
138
+ <svg aria-hidden =" true" ></svg >
139
+ ```
0 commit comments