Preview SVG inside JavaScript in VSCode
Asked Answered
S

2

15

Is it possible to preview SVG inside JavaScript in VSCode?

There are plugins that can preview SVG files in VSCode, but what if they're inside JavaScript or React components? Or if there's a list of compound paths in an object.

There are also tools like Storybook but what if you just want to quickly preview some SVGs? If they're inside JS they're probably dynamic (take props like fill, color, etc), but could I then just preview them with the defaults (if provided), or a simple way to provide them props?

Any VSCode plugin that does that? How do people tackle this?

Sandon answered 10/12, 2019 at 11:23 Comment(1)
hi @zok! have you found a solution for this yet?Gnome
E
6

I'm using this extension to preview svg files inside vscode.

In your case, if the whole svg code is embedded in js script file, you can copy the code and paste it in an empty editor you don't need to save it, you just need to specify the type as svg then run the command Preview SVG.

Epidote answered 10/12, 2019 at 11:33 Comment(0)
B
1

This extension allows you to preview inline SVGs. It works with js files and also with SVGs inside strings.

It doesn't update automatically when you change the svg. But you can bind the command to a keyboard shortcut, and it gets pretty fast.

Bourque answered 17/10, 2023 at 18:21 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.