Skip to content

Commit 2ea6312

Browse files
committed
[Icons] explain svg colors and improve example configuration
1 parent e653f48 commit 2ea6312

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Icons/doc/index.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ define the HTML attributes added to the ``<svg>`` element:
8383
{{ ux_icon('user-profile', {height: '16px', width: '16px', 'aria-hidden': true}) }}
8484
{# renders <svg height="16" width="16" aria-hidden="true"> ... </svg> #}
8585

86+
Typically, icon SVG use `fill='currentColor'` to inherit the color of the containing
87+
element. You can use CSS to set the color either on the containing element or in a class
88+
or style attribute of the icon itself.
8689

8790
Icon Sets
8891
~~~~~~~~~
@@ -324,17 +327,17 @@ added to all icons unless overridden by the second argument of the ``ux_icon`` f
324327
# config/packages/ux_icons.yaml
325328
ux_icons:
326329
default_icon_attributes:
327-
fill: currentColor
330+
style: "color: white;"
328331
329-
Now, all icons will have the ``fill`` attribute set to ``currentColor`` by default.
332+
Now, all icons will have the ``style`` attribute set to ``color: white;`` by default.
330333

331334
.. code-block:: twig
332335
333-
# renders "user-profile.svg" with fill="currentColor"
336+
# renders "user-profile.svg" with style="color: white;"
334337
{{ ux_icon('user-profile') }}
335338
336-
# renders "user-profile.svg" with fill="red"
337-
{{ ux_icon('user-profile', {fill: 'red'}) }}
339+
# renders "user-profile.svg" with style="color: red"
340+
{{ ux_icon('user-profile', {style: 'color: red;'}) }}
338341
339342
Icon Aliases
340343
~~~~~~~~~~~~
@@ -546,7 +549,7 @@ Full Configuration
546549
547550
# Default attributes to add to all icons
548551
default_icon_attributes:
549-
fill: currentColor
552+
style: 'color: white;'
550553
'font-size': '1.25em'
551554
552555
# Icon aliases (alias => icon name)

0 commit comments

Comments
 (0)