You need to sign in to do that
Don't have an account?
Sabina
LWC: Use the same SVG file in both the bundle .svg and .html files
Hello,
I want to use the same icon both as LWC icon (in the .svg bundle file) and as header icon in the .html file for multiple components. Is there a way to achieve this without duplicating the code?
I can use a static resource for the header icons of multiple componentsm but can't access it in the .svg files.
Also, can I somehow access the local .svg file into the .html file of the same bundle?
Thank you!
Sabina
I want to use the same icon both as LWC icon (in the .svg bundle file) and as header icon in the .html file for multiple components. Is there a way to achieve this without duplicating the code?
I can use a static resource for the header icons of multiple componentsm but can't access it in the .svg files.
Also, can I somehow access the local .svg file into the .html file of the same bundle?
Thank you!
Sabina
Unfortunately, it is not possible today to access the local .svg file into the .html file of the same bundle. One option would be to create a build script that runs before you deploy that would copy the SVG files from a single source of truth
Also you can try creating a reusable LWC just for svg and you can include it any where you want. However, you cannot add this as LWC icon in the app builder
If the above information helps answer your question, please mark this as Best Answer so that it may help others in the community. Thank You!
Anudeep
All Answers
Unfortunately, it is not possible today to access the local .svg file into the .html file of the same bundle. One option would be to create a build script that runs before you deploy that would copy the SVG files from a single source of truth
Also you can try creating a reusable LWC just for svg and you can include it any where you want. However, you cannot add this as LWC icon in the app builder
If the above information helps answer your question, please mark this as Best Answer so that it may help others in the community. Thank You!
Anudeep