Skip to content

Commit ec11c9c

Browse files
committed
[Icons] explain svg size
1 parent e653f48 commit ec11c9c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Icons/doc/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ 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+
.. note::
87+
88+
Without size instructions, ``<svg>`` elements will be dynamically sized by the browser.
89+
For icons, we therefore recommend to explicitly set the size. This can be done with a
90+
CSS class or a height attribute in pixels, with variables of your CSS framework or using
91+
``em`` to set the size in relation to the font size of the current element.
92+
93+
Note that it is enough to specify the height, the width will be adjusted accordingly:
94+
95+
.. code-block:: twig
96+
97+
{{ ux_icon('user-profile', {style: 'height: 1em;'}) }}
98+
99+
For a consistent look, you might want to set the size through a
100+
:ref:`default attribute <icons_default_attributes>`.
86101

87102
Icon Sets
88103
~~~~~~~~~
@@ -313,6 +328,8 @@ HTML Syntax
313328

314329
``symfony/ux-twig-component`` is required to use the HTML syntax.
315330

331+
.. _icons_default_attributes:
332+
316333
Default Attributes
317334
~~~~~~~~~~~~~~~~~~
318335

0 commit comments

Comments
 (0)