Skip to content

Rendering SVG elements in rsx! generated via a JS function/wasm-bindgen #453

Answered by jkelleyrtp
michaelhagel asked this question in Q&A
Discussion options

You must be logged in to vote

If you're getting plain SVG back from the provider, then you can use dangerous_inner_html directly. It should also be faster.

https://dioxuslabs.com/guide/elements/special_attributes.html#the-html-escape-hatch-dangerous_inner_html

I do the same for some plotly charts I've made before:

https://github.com/jkelleyrtp/marketplace/blob/30d72660a6e1c4f33035223e377725b61bc54b2a/src/components/results.rs#L290-L327

We also use this approach in loading pre-rendered markdown into the docsite:

https://github.com/DioxusLabs/docsite/blob/master/src/components/blog/mod.rs#L89

If you're not getting plain SVG and need to call the script:

We have a use_eval hook that lets you call JS directly.

An alternati…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@michaelhagel
Comment options

Answer selected by michaelhagel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants