Native support for SVG-use at icons
See original GitHub issueHi guys! I am starting to use SVG icons. An optimal way is to save these icons in a single file and display them with “svg use”. In my case, the SVG-collection is generated by an external process not related to quasar.
<q-icon>
<svg><use xlink:href='/assets/icons.svg#folder'/></svg>
</q-icon>
is working perfect. Unfortunately there are still many places where this approach does not work. This procedure cannot be used e.g. for “dropdown-icon” and other specifications like these. Would it be possible to use an abbreviation that works similar to the “img” keyword, for example “svguse”? It could be used like this:
<q-btn-dropdown
icon="svguse:/assets/icons.svg#folder"
dropdown-icon="svguse:/assets/icons.svg#chevron-down'"
/>
Maybe this could become a general functionality, so it could be used everywhere like e.g. with q-img, too. IMHO advantages of the svg-use solution is that one can more easily create own icons with a low footprint and work towards getting rid of the symbol fonts.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:5 (4 by maintainers)
Top GitHub Comments
Will be available when Quasar-v1.12.13 is released later today.
In similar fashion to svguse:, would it be possible to add just svg: switch that loads a string supplied as an inline svg?
Please see my qicon override attached that loads a string as a svg node. It also merges in attributes passed from the parent component (i.e. q-tab).
Extras:
<script>
tags from supplied svg string, but it probably won’t be required for general implementation.html:
injector that loads the supplied string as pure HTML string/node as quasar icon. This needs to be a pre-compiled HTML - I couldn’t figure out how to load a .vue template here and get it compiled on the fly by the vue template compiler.usage:
svg loaded as an icon in q-tab:
<q-tab name="something" :icon="'svg:'+mail" label="something" extra_attribute="hello"/>
importing svg string into my component:
import { mail } from "@/js/quasar/icons/myicons.js";
making the imported svg string available to vue template:
qicon.txt
Current svg loader implementations in quasar have some drawbacks:
@webnoob What do you think?